JavaWeb项目练习(学生选课管理系统)三【登录功能】
需求:
首页为用户登录页面,管理员,教师,学生三种角色用户登录后,进入相应的功能页。
在index.jsp文件里跳转到login.jsp页面,为了更好地书写
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>首页</title> <link rel="shortcut icon" href="#"/> </head> <body> <jsp:include page="WEB-INF/login.jsp"/> </body> </html>
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/style.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/index_work.css">
<style>
#cont {
text-align: center;
margin-left: 240px;
padding: 20px;
}
</style>
</head>
<body>
<jsp:include page="top.jsp"/>
<div id="cont" style="margin-top: 140px ">
<form method="post" action="${pageContext.request.contextPath}/LoginServlet?type=trueLogin">
<div style="margin-top: 30px">
<label style="color: white">
用户名:
<input type="text" name="username">
</label>
</div>
<div style="margin-top: 30px">
<label style="color: white">
密码:
<input type="password" name="password">
</label>
</div>
<div style="margin-top: 30px; padding-left: 60px" >
<select name="state">
<option>管理员</option>
<option>教师</option>
<option>学生</option>
</select>
</div>
<div style="margin-top:50px">
<input type="submit" value="登录">
</div>
<jsp:include page="bottom.jsp"/>
</form>
<h1 style="color: white">${mes}</h1>
</div>
</body>
<%request.getSession().setAttribute("mes", null);%>
</html>
将提交的信息放在LoginServlet层上面


浙公网安备 33010602011771号