spring+hibernate+pager taglib实现分页(底层也做了分页)(三)

下面说说表现层,代码如下:

xml 代码
  1. <%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%>
  2. <%@tagliburi="/WEB-INF/struts-html.tld"prefix="html"%>
  3. <%@tagliburi="/WEB-INF/c.tld"prefix="c"%>
  4. <%@tagliburi="http://jsptags.com/tags/navigation/pager"prefix="pg"%>
  5. <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
  6. <scripttype="text/javascript">
js 代码
  1. //修改每页显示的记录数
  2. functionchangePageSize(){
  3. document.forms[0].submit();
  4. }
  5. //直接跳转到某个页面
  6. functionjumpPage(){
  7. varpage=document.getElementById('page').value;
  8. varoffset=(page-1)*document.getElementsByName('pageDisplay')[0].value;
  9. document.location.href('check.do?pager.offset='+offset+'&page='+page);
  10. }
xml 代码
  1. </script>
  2. <html>
  3. <head>
  4. <title>MyJSP'index.jsp'startingpage</title>
  5. <metahttp-equiv="pragma"content="no-cache">
  6. <metahttp-equiv="cache-control"content="no-cache">
  7. <metahttp-equiv="expires"content="0">
  8. <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
  9. <metahttp-equiv="description"content="Thisismypage">
  10. <!-- </span></li> <li class=""><span><span class="comments"><linkrel="stylesheet"type="text/css"href="styles.css"> </span></span></li> <li class="alt"><span><span class="comments">-->
  11. </head>
  12. <body>
  13. <!--查询条件部分-->
  14. <html:formaction="/check.do"method="post">
  15. <table>
  16. <tr>
  17. <td>
  18. 内容:
  19. </td>
  20. </tr>
  21. <tr>
  22. <td>
  23. <html:textproperty="content"/>
  24. </td>
  25. </tr>
  26. <tr>
  27. <td>
  28. <inputtype="submit"/>
  29. </td>
  30. </tr>
  31. </table>
  32. <!--数据显示部分-->
  33. <c:iftest="${result!=null}">
  34. <pg:pageritems="${count}"maxPageItems="${pageSize}"index="center"maxIndexPages="5"export="offset,currentPageNumber=pageNumber"scope="request"url="check.do">
  35. 数据:<br/>
  36. <tablewidth="100%"border="1">
  37. <c:forEachitems="${result}"var="subpage">
  38. <tr>
  39. <td>
  40. <c:outvalue="${subpage.content}"></c:out>
  41. </td>
  42. <td>
  43. <c:outvalue="${subpage.intValue}"></c:out>
  44. </td>
  45. </tr>
  46. </c:forEach>
  47. </table>
  48. <pg:index>
  49. <selectid="page"onchange="jumpPage();">
  50. <pg:pages>
  51. <c:iftest="${pageNumber==currentPageNumber}">
  52. <optionvalue="${pageNumber}"selected="selected">${pageNumber}</option>
  53. </c:if>
  54. <c:iftest="${pageNumber!=currentPageNumber}">
  55. <optionvalue="${pageNumber}">${pageNumber}</option>
  56. </c:if>
  57. </pg:pages>
  58. </select>
  59. <c:outvalue="${totalPage}"></c:out>
  60. <pg:first>
  61. <ahref="<%=pageUrl%>&page=${pageNumber}">首页</a>
  62. </pg:first>
  63. <pg:prev>
  64. <ahref="<%=pageUrl%>&page=${pageNumber}">上一页</a>
  65. </pg:prev>
  66. <pg:next>
  67. <ahref="<%=pageUrl%>&page=${pageNumber}">下一页</a>
  68. </pg:next>
  69. <pg:last>
  70. <ahref="<%=pageUrl%>&page=${pageNumber}">末页</a>
  71. </pg:last>
  72. 共${count}条记录
  73. 每页显示
  74. <html:textproperty="pageDisplay"onchange="changePageSize();"/>
  75. 条记录
  76. </pg:index>
  77. </pg:pager>
  78. </c:if>
  79. </html:form>
  80. </body>
  81. </html>

你可能感兴趣的:(spring,C++,c,Hibernate,C#)