Skip to content

Commit 59dbb6e

Browse files
author
xiachaochao
committed
个人网站登录界面
1 parent 70219be commit 59dbb6e

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4+
<html>
5+
<head>
6+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7+
<title>Insert title here</title>
8+
</head>
9+
<body>
10+
<h1>这是错误页面</h1>
11+
</body>
12+
</html>

JavaWeb/WebContent/MySite/JSP/login.jsp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,35 @@
88
</head>
99
<body>
1010
<form action="login.jsp" method="post">
11-
用户名:<input type="text" name="uname"><br>
12-
&nbsp;&nbsp;码:<input type="password" name="upass"><br>
13-
<input type="submit" value="登录">
14-
<input type="reset" value="重置">
11+
用户名:<input type="text" name="uname"><br> 密&nbsp;&nbsp;码:<input
12+
type="password" name="upass"><br> <input type="submit"
13+
value="登录"> <input type="reset" value="重置">
1514
</form>
1615
<%
1716
String name = request.getParameter("uname");
1817
String password = request.getParameter("upass");
19-
if (name != null||password==null||"".equals(password)) {
20-
if("crazy".equals(name)&&"123456".equals(password)){
21-
response.setHeader("refresh","2;URL=welcome.jsp");//实现定时跳转
22-
session.setAttribute("userid",name);
18+
if (!(name == null || password == null || "".equals(password))) {
19+
if ("crazy".equals(name) && "123456".equals(password)) {
20+
/* response.setHeader("refresh", "2;URL=welcome.jsp");//实现定时跳转 */
21+
%>
22+
<jsp:forward page="welcome.jsp"></jsp:forward>
23+
<%
24+
session.setAttribute("userid", name);
2325
}
2426
%>
25-
<h3>用户登录成功,两秒后跳转到欢迎页</h3>
26-
<h3>如果没有跳转,请按<a href="welcome.jsp">这里</a></h3>
27-
<%
28-
}else{
27+
<h3>用户登录成功,两秒后跳转到欢迎页</h3>
28+
<h3>
29+
如果没有跳转,请按<a href="welcome.jsp">这里</a>
30+
</h3>
31+
<%
32+
} else {
2933
%>
3034
<h3>错误的用户或密码!</h3>
31-
<%} %>
35+
<%-- <%
36+
/* response.setHeader("refresh","0;URL=logError.jsp"); */%> --%>
37+
<jsp:forward page="logError.jsp"></jsp:forward>
38+
<%
39+
}
40+
%>
3241
</body>
3342
</html>

0 commit comments

Comments
 (0)