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">
                用户名:&nbsp;
                <input type="text" name="username">
            </label>
        </div>

        <div style="margin-top: 30px">
            <label style="color: white">
                &nbsp; &nbsp;密码:&nbsp;
                <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">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" value="登录">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <jsp:include page="bottom.jsp"/>
    </form>
    <h1 style="color: white">${mes}</h1>
</div>
</body>
<%request.getSession().setAttribute("mes", null);%>
</html>

将提交的信息放在LoginServlet层上面

 

posted @ 2022-12-01 22:58  喝着农药吐泡泡o  阅读(181)  评论(0编辑  收藏  举报