打卡
今天自习完成了之前的一个审核的问题,就是将学生提交的信息单独存储在一个表,在管理员登录审核时显示在页面上。我在这上面做的时输入,也可以设置为单选是否通过。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<tr>
<th>username</th>
<th>password</th>
<th>审核</th>
</tr>
<c:forEach var="persons" items="${person}">
<tr>
<td>${persons.username}</td>
<td>${persons.password}</td>
<td><input type ="text" name = " jg" ></td>
</tr>
</c:forEach>
</table>
<input type = "button" value = "提交" onclick="location.href='two'">
</body>
</html>
这个是网页的源代码,提交之后转到另外的servlet处理,就是判断审核的信息,在进行添加到另外的表。
package Bean; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class oneServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTf-8"); response.setContentType("text/html;charset=UTF-8"); List<Person> person = text.xs(); // PrintWriter out = response.getWriter(); // out.print(person.toString()); request.setAttribute("person", person); request.getRequestDispatcher("one.jsp").forward(request, response); // request.getRequestDispatcher("two.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
这是我第一个处理输出到页面的servlet。