首先在×××controller里查询数据,并绑定,代码如下:
1 /** 2 * 显示所有租借信息 默认进入这个方法 3 * 4 * @param resp 5 * @param req 6 * @param manage 7 * @return 8 * @throws IOException 9 */ 10 @RequestMapping(method = RequestMethod.GET) 11 public String showApply(HttpServletResponse resp, HttpServletRequest req,Apply apply) throws IOException { 12 resp.setContentType("text/html;charset=UTF-8"); 13 req.setCharacterEncoding("utf-8"); 14 List<Apply> lst = lwlService.getApply(apply); 15 req.setAttribute("lstApply", lst); 16 return "showApply"; 17 }
然后前端页面顶部引入:
1 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
具体显示代码:
1 <body> 2 <div class="tableDiv"> 3 <h3 style="text-align: center">物品申领页面显示详情</h3> 4 5 <a href="${pageContext.request.contextPath}/goods/goApply"> 6 <b>物品申领</b> 7 </a> 8 9 <a href="${pageContext.request.contextPath}/lwl"> 10 <b>管理物品</b> 11 </a> 12 13 <%--查询--%> 14 <form action="${pageContext.request.contextPath}/goods"> 15 <input type="text" name="goodsName" placeholder="请输入要查询的关键字(name字段)" class="inputSearch"> 16 <input id="btnSearch" type="submit" value="查询" class="btnSearch"> 17 </form> 18 19 <table class="table"> 20 <tr id="yes" style="background-color: deepskyblue ;color: white;"> 21 <td>物品名称</td> 22 <td>领用人员</td> 23 <td>领用日期</td> 24 <td>领用数量</td> 25 <td>备注说明</td> 26 </tr> 27 <c:forEach items="${requestScope.lstApply}" var="y"> 28 <fmt:parseDate value="${y.applyTime}" var="time" pattern="yyyy-mm-dd"/> 29 <tr id="yes${y.goodsName}"> 30 <td>${y.goodsName}</td> 31 <td>${y.applyName}</td> 32 <td><fmt:formatDate value="${time}" type="date"/></td> 33 <td>${y.applyCount}</td> 34 <td><div class="applyExpDiv" title="${y.applyExp}"> ${y.applyExp}</div></td> 35 </tr> 36 </c:forEach> 37 </table> 38 </div> 39 </body>