前端界面部分:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="login_result.jsp"method="post">
<h1 align="center">用户登录</h1>
<table align="center">
<tr>
<td>用户名称:</td>
<td><input type="text" value="" name="id"/></td>
</tr>
<tr>
<td>用户密码:</td>
<td><input type="password" value="" name="pass"/></td>
</tr>
<tr>
<td><input type="reset" value="重置键"></td>
<td><input type="submit"></td>
</tr>
</table>
</form>
</body>
</html></html>
后台进行死数据对比:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
//1 获取页面上的登录信息
String id =request.getParameter("id");//获取账号
String pass = request.getParameter("pass");//获取密码
//2 登录验证(跟自己的QQ账号密码比,比死的:下去把自己的账号密码和文件中对比;后期跟数据库中对比,比活的)
if(id.equals("123") && pass.equals("1234")){
//登陆成功
response.sendRedirect("login1.jsp");
}else{
%>
<jsp:forward page = "login2.jsp"></jsp:forward>
<%
}
%>
</body>
</html>
输入正确跳转的界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
主页正在开发,敬请期待。。。。。
</body>
</html>
输入错误的界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
登录失败,请<a href="login.jsp" >重新登录</a>
</body>
</html>