4.18

发布时间 2023-04-19 23:43:01作者: 王者归来蔡徐

所花时间(包括上课):4h

代码量(行):200行

博客量(篇):1篇

晚上学习

我了解到的知识点:

今天我修复了昨天传参报错的问题,改善了页面乱码的问题,实现了功能流畅运行,完成了组长交给的任务

遇到的问题,session传值问题,我不会多值传参,只会一个,不过好在可以改

<%@page import="DAO.dao"%>
<%@ page import="java.sql.*" language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="dao" class="DAO.dao" scope="page"/>
<%

request.setCharacterEncoding("utf-8");
String id=(String)request.getParameter("id");
String password=(String)request.getParameter("password");
int status=dao.panduan(id);
String getstatus=String.valueOf(status);
session.setAttribute("status", status);
Cookie c1 = new Cookie("id",id);// 新建一个Cookie对象
Cookie c2 = new Cookie("password",password);
Cookie c3 = new Cookie("status",getstatus);
c1.setMaxAge(60*60);
c1.setMaxAge(60*60);
c3.setMaxAge(60*60);
response.addCookie(c1);
response.addCookie(c2);
response.addCookie(c3);
if(password.equals(dao.search(id))){
if(status==1||status==3){
response.sendRedirect("main.jsp");
}
}else{
out.print("<script language='javaScript'> alert('账号错误/学生身份');</script>");
response.setHeader("refresh", "0;url=login.jsp");
}


%>
</body>
</html>

 

 

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
</head>
<style>
body {
background-color: gainsboro;
font-size: 16px;
}

.div_top_1 {
height: 140px;
width: 100%;
}

.div_top_2 {
height: 50px;
width: 100%;
}

.main {
width: 417.683px;
height: 440px;
background-color: #FFFFFF;
margin: 0 auto;

}

.login {

width: 360px;
height: 360px;
background-color: #FFFFFF;
margin: 0 auto
}

.div_login_head {
height: 36px;
background-color: #FFFFFF;
margin: 0 auto;
line-height: 36px;
text-align: center;
color: #666;
border-bottom: 3px solid #21b351;
font-size: 18px;
line-height: 24px;
margin-bottom: -1px;
font-family: "PingFang SC", "Microsoft yahei", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

.div_input_account {
width: 360px;
height: 40px;

}

.div_input_pwd {
width: 360px;
height: 24px;

}

.input_account, .input_pwd {
width: 360px;
height: 40px;
border: none;
border-bottom: #ddd 1px solid;
border-radius: 0;
outline: 0;
font: inherit;
font-size: .875rem;
}

.div_button_login {
width: 360px;
height: 40px;
margin-top: 36px;
text-align: center;

}

.button_login {
width: 180px;
height: 40px;
background: #1fa54a;
font-size: 16px;
cursor: pointer;
color: white;
border: none;
border-radius: 2px;
outline: 0;

}

.div_empty {
width: 360px;
height: 24px;

}
.div_error {
width: 360px;
height: 24px;
text-align: center;
}
.span_error{

color: #e35b5a;
font-size: 13px;
}
</style>
<body>
<title>人脸识别登录页面</title>
<div class="center" align="center" >
<h1 style="color:blue">欢迎登录人脸识别签到系统</h1>

<div class="div_top_1">


</div>
<div class="main">
<div class="login">
<div class="div_top_2">

</div>
<div class="div_login_head">
密码登录
</div>

<div class="div_empty">
</div>
<form action="check.jsp" method="get">
<div class="div_input_account">
<input class="input_account" type="text" name="id" placeholder="用户名" value="${userName }"/>
</div>

<div class="div_empty">
</div>


<div class="div_input_pwd">
<input class="input_pwd" type="password" name="password" placeholder="密码" value="${password }"/>
</div>
<div class="div_empty">
</div>
<div class="div_error">
<span class="span_error"> ${errorMessage }</span>
</div>
<div class="div_button_login">
<input class="button_login" type="submit" value="登&nbsp;&nbsp;录"/>
</div>
<div >
<br><a href="zhuce.jsp">没有账号?注册</a>
</div>
</form>
</div>


</div>

</div>
</body>
</html>