📄 page.tag
字号:
<%@ tag body-content="empty" pageEncoding="GBK"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@ attribute name="tableName" required="true" %> <!-- 表名 --><%@ attribute name="columnNames" required="true"%> <!-- 列名 --><%@ attribute name="rowsPerPage" required="true" %> <!-- 每页显示的行数 --><%@ attribute name="primaryKey" required="true" %> <!-- 主键字段 --><%@ attribute name="location" required="true" %> <!-- 重定向的页面 --><%@ attribute name="titles" required="false" %> <!-- 表头 --><%@ attribute name="width" required="false" %> <!-- 表格宽度 --><%@ attribute name="align" required="false" %> <!-- 对齐方式 --><jsp:useBean id="page2" scope="request" class="page.PageBean"/><!-- 将value的值储存至target对象的属性中 --><c:set value="${tableName}" target="${page2}" property="tableName"/><c:set value="${columnNames}" target="${page2}" property="columnNames"/><c:set value="${rowsPerPage}" target="${page2}" property="rowsPerPage"/><c:set value="${primaryKey}" target="${page2}" property="primaryKey"/><script type="text/javascript"> <!-- function Jumping() { document.PageForm.submit(); return; } function gotoPage(pagenum) { document.PageForm.jumpPage.value = pagenum; document.PageForm.submit(); return; } --></script><table border="1" align="${align}" width="${width}"> <!-- 判断是否有表头属性,如果有则输出表头 --> <c:if test="${not empty titles}"> <tr> <c:forTokens delims="," items="${titles}" var="title"> <th>${title}</th> </c:forTokens> </tr> </c:if> <!-- 显示本页的数据 --> <c:forEach var="row" items="${page2.data}"> <tr align="${align}"> <c:forEach var="col" items="${row}"> <td align="center">${col}</td> </c:forEach> </tr> </c:forEach></table><div align="${align}"> <!-- 判断总页数是否多于1页 --> <c:if test="${page2.maxPage != 1}"> <form action="/PageModule/pageservlet" name="PageForm" method="POST"> 每页${page2.rowsPerPage}行 共${page2.maxRowCount}行 第${page2.curPage}页 共${page2.maxPage}页 <br /> <c:choose> <c:when test="${page2.curPage == 1}"> 首页 上一页 </c:when> <c:otherwise> <a href="javascript:gotoPage(1)">首页</a> <a href="javascript:gotoPage(${page2.curPage - 1})">上一页</a> </c:otherwise> </c:choose> <c:choose> <c:when test="${page2.curPage == page2.maxPage}"> 下一页 尾页 </c:when> <c:otherwise> <a href="javascript:gotoPage(${page2.curPage + 1})">下一页</a> <a href="javascript:gotoPage(${page2.maxPage})">尾页</a> </c:otherwise> </c:choose> 转到第 <select name="jumpPage" onchange="Jumping()"> <c:forEach var="i" begin="1" end="${page2.maxPage}" step="1"> <c:choose> <c:when test="${i == page2.curPage}"> <option selected="selected" value="${i}">${i}</option> </c:when> <c:otherwise> <option value="${i}">${i}</option> </c:otherwise> </c:choose> </c:forEach> </select> <input type="hidden" name="location" value="${location}"/> </form> </c:if></div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -