學生管理系統(跳轉頁面設計)
阿新 • • 發佈:2018-12-23
新增頁面。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="<%=request.getContextPath()%>/js/studentAdd.js"></script> <style type="text/css"> h1 { color: #62a8ea; } tr, td { color: gray; } .submit { color: #62a8ea } .button { color: #62a8ea } </style> </head> <body> <h1>新增頁面</h1> <hr> <form action="<%=request.getContextPath()%>/StudentServlet?function=addStudent" onsubmit="return verify();" method="post"> <table> <tr> <td>使用者名稱:</td> <td><input type="text" name="username" id="username"></td> </tr> <tr> <td>密碼:</td> <td><input type="text" name="password" id="password"></td> </tr> <tr> <td>姓名:</td> <td><input type="text" name="name" id="name"></td> </tr> <tr> <td>性別:</td> <td><input type="radio" name="gender" value="男">男 <input type="radio" name="gender" value="女">女</td> </tr> <tr> <td>年齡:</td> <td><input type="text" name="age" id="age"></td> </tr> <tr> <td>地址:</td> <td><input type="text" name="address" id="address"></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="regdate" id="regdate"></td> </tr> <tr> <td><input class="submit" type="submit" value="提交"></td> <td><input class="button" type="button" value="取消" onclick="cancel();"></td> </tr> </table> </form> </body> </html>
修改頁面。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <script type="text/javascript" src="<%=request.getContextPath()%>/js/studentAlter.js"></script> <style type="text/css"> h1 { color: #62a8ea; } tr, td { color: gray; } .submit { color: #62a8ea } .button { color: #62a8ea } </style> <body> <h1>修改頁面</h1> <hr> <form action="<%=request.getContextPath()%>/StudentServlet?function=alterStudent" onsubmit="return verify();" method="post"> <table> <tr> <td><input type="text" style="display: none;" name="id" id="id" value="${student.id }"></td> </tr> <tr> <td>使用者名稱:</td> <td><input type="text" name="username" id="username" value="${student.username }"></td> </tr> <tr> <td>密碼:</td> <td><input type="text" name="password" id="password" value="${student.password }"></td> </tr> <tr> <td>姓名:</td> <td><input type="text" name="name" id="name" value="${student.name }"></td> </tr> <tr> <td>性別:</td> <td><c:if test="${student.gender =='男'}"> <input type="radio" checked="checked" name="gender" value="男">男 <input type="radio" name="gender" value="女">女 </c:if> <c:if test="${student.gender =='女'}"> <input type="radio" name="gender" value="男">男 <input type="radio" checked="checked" name="gender" value="女">女 </c:if></td> </tr> <tr> <td>年齡:</td> <td><input type="text" name="age" id="age" value="${student.age }"></td> </tr> <tr> <td>地址:</td> <td><input type="text" name="address" id="address" value="${student.address }"></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="regdate" id="regdate" value="${student.regdate }"></td> </tr> <tr> <td><input class="submit" type="submit" value="提交"></td> <td><input class="button" type="button" value="取消" onclick="cancel();"></td> </tr> </table> </form> </body> </html>
整體顯示頁面。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style type="text/css"> #main { margin-left: 150px; margin-top: 80px; } table { border: solid #62a8ea; } th, td { height: 30px; width: 80px; text-align: center; color: gray; } th { color: #62a8ea; } a { text-decoration: none; } #add_div { margin-left: 726px; } #add_input { border: 3px solid green; padding-bottom: 4px; padding-top: 4px; padding-left: 8px; padding-right: 8px; } </style> <script type="text/javascript" src="<%=request.getContextPath()%>/js/studentList.js"> </script> </head> <body> <div id="main"> <div id="add_div"> <input id="add_input" type="button" onclick="goAdd();" value="增加"> </div> <div id="table"> <table border="1px solid gray"> <tr> <th>編號</th> <th>使用者名稱</th> <th>密碼</th> <th>姓名</th> <th>性別</th> <th>年齡</th> <th>地址</th> <th>日期</th> <th>操作</th> </tr> <c:forEach var="student" items="${ students}"> <tr> <td>${ student.id}</td> <td>${ student.username}</td> <td>${ student.password}</td> <td>${ student.name}</td> <td>${ student.gender}</td> <td>${ student.age}</td> <td>${ student.address}</td> <td>${ student.regdate}</td> <td><a style="color: orange;" href="http://localhost:8080/studentManager/StudentServlet?function=delStudent&id=${student.id}">刪除</a><a style="color: blue;" href="http://localhost:8080/studentManager/StudentServlet?function=goAlter&id=${student.id}">修改</a></td> </tr> </c:forEach> </table> </div> </div> </body> </html>
登陸頁面。
<%@page import="java.net.URLEncoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/login.js"></script>
</head>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
</style>
<body>
<%
Object errorMessage = session.getAttribute("errorMessage");
out.print(errorMessage);
%>
<%
String username = "";
String password = "";
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equals("username")) {
username = URLEncoder.encode(cookie.getValue(), "utf-8");
}
if (cookie.getName().equals("password")) {
password = URLEncoder.encode(cookie.getValue(), "utf-8");
}
}
%>
<div id="body">
<div id="title">
<h1>登陸頁面</h1>
<hr>
</div>
<form
action="<%=request.getContextPath()%>/LoginServlet?function=login"
onsubmit="return login();" method="post">
<table>
<tr>
<td>使用者名稱:</td>
<td><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="text" id="password" name="password"></td>
</tr>
<tr>
<td><input type="checkbox" checked="checked" name="remember"
value="1"></td>
<td>記住我的選擇</td>
</tr>
<tr>
<td><input type="submit" value="登陸"></td>
<td><input type="button" value="註冊" onclick="reRegister();"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
登陸成功頁面。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<style type="text/css">
#body {
background: orange;
}
</style>
<body>
<div id="body">
<h1>登陸成功</h1>
<hr>
</div>
</body>
</html>
註冊頁面。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/register.js"></script>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
</style>
</head>
<body>
<div id="body">
<div id="title">
<h1>註冊頁面</h1>
<hr>
</div>
<form
action="<%=request.getContextPath()%>/RegisterServlet?function=register"
onsubmit=" return register();" method="post">
<table>
<tr>
<td>使用者名稱:</td>
<td><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" id="password" name="password"></td>
</tr>
<tr>
<td>姓名:</td>
<td><input type="text" id="name" name="name"></td>
</tr>
<tr>
<td>性別:</td>
<td><input type="radio" name="gender" value="男">男 <input
type="radio" name="gender" value="女">女</td>
</tr>
<tr>
<td>年齡:</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td>地址:</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>註冊時間:</td>
<td><input type="text" name="regdate"></td>
</tr>
<tr>
<td><input type="submit" value="提交"></td>
<td><input type="button" value="取消" onclick="cancle();"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
註冊狀態頁面。
<%@page import="com.wh.action.RegisterServlet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
import="com.wh.utils.RegisterStatus " pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<style type="text/css">
#body {
background: orange;
}
#title {
background: graytext;
text-align: center;
}
.href{
color: orange;
}
</style>
<body>
<div id="body">
<div id="title">
<h1>註冊狀態頁面</h1>
<hr>
</div>
<%
RegisterStatus status = (RegisterStatus) request.getAttribute("rs");
String contextPath = request.getContextPath();
if (RegisterStatus.SUCCESS == status) {
out.print("<h1>註冊成功</h1><a href=" + contextPath + "/LoginServlet?function=reLogin>請點選登陸<a>");
} else if (RegisterStatus.FAILURE == status) {
out.print("<h2>註冊失敗</h2><a href=" + contextPath + "/RegisterServlet?function=reRegister>請點選重新註冊<a>");
} else if (RegisterStatus.REAISTERED == status) {
out.print("<h3>已註冊</h3><a href=" + contextPath + "/RegisterServlet?function=reRegister>請點選重新註冊<a>");
}
%>
</div>
</body>
</html>