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层上面
本文作者:TranquilTimber
本文链接:https://www.cnblogs.com/gbrr/p/16943078.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
分类:
JAVA / JAVAWEB
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步