JSTL的使用

批量显示数据
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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </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>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值