批量显示数据
public void getEmpList(HttpServletRequest req, HttpServletResponse resp) throws Exception{
String kw = req.getParameter("kw");
Integer cp = Integer.parseInt(req.getParameter("cp"));
Integer ls = Integer.parseInt(req.getParameter("ls"));
Map<String, Object> map = empService.findAllSplit(kw, cp, ls);
req.setAttribute("map", map);
req.getRequestDispatcher("/Pages/emp.jsp").forward(req, resp);
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
String pathInfo = req.getPathInfo();
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
try {
if("/login".equals(pathInfo)){
this.login(req, resp);
}else if ("/regist".equals(pathInfo)) {
this.regist(req, resp);
}else if ("/remove".equals(pathInfo)) {
this.removeById(req, resp);
}else if ("/get".equals(pathInfo)) {
this.getEmpById(req,resp);
}else if ("/list".equals(pathInfo)) {
this.getEmpList(req,resp);
}
} catch (Exception e) {
e.printStackTrace();
}
}
<%@ page language="java" contentType = "text/html;charset=utf-8" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'emp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<h1>显示雇员的信息:${map['list']}
</h1>
<table border="1">
<tr>
<td>编号</td>
<td>姓名</td>
<td>职位</td>
<td>薪资</td>
<td>领导编号</td>
<td>入职日期</td>
<td>佣金</td>
<td>部门编号</td>
<td>照片</td>
<td>删除</td>
</tr>
<c:forEach items="${map['list']}" var ="emp">
<tr>
<td>${emp.empno}</td>
<td>${emp.ename}</td>
<td>${emp.job}</td>
<td>${emp.sal}</td>
<td>${emp.mgr}</td>
<td>${emp.hiredate}</td>
<td>${emp.comm}</td>
<td>${emp.deptno}</td>
</tr>
</c:forEach>
</table>
</body>
</html>