JAVA日报

java复习

发现了一个重大问题:

查的显示和操作没有放到servlet中

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="bean.*" %>
<%@ page import="dao.*" %>
<%@ page import="java.util.ArrayList" %>
<!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>
<%request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html; charset=utf-8");
ArrayList<Course> courses=new Coursedao().getAlluserinfos();
String role=request.getParameter("role");
String value=request.getParameter("value");
if(courses==null){
courses=new ArrayList<>();
}
%>
</head>
<body>
<table border="1" >
<tr>
<th>id</th>
<th>name</th>
</tr>
<% for(Course course:courses){
if(course.get(role).equals(value)){
%>
<tr>
<td><%=course.getNum()%></td>
<td><%=course.getName()%></td>
</tr>
<%
}}
%>
</table>
<button type="button" onclick="history.back(-1);">返回</button>
</body>
</html>

原文地址:https://www.cnblogs.com/mumulailai/p/14162864.html