jstl分页
效果:
注释:
totalPage(总页数):全部记录数/每页的记录数
page:当前的页码
<c:if test="${totalPage!=1}">
<c:choose>
<c:when test="${requestScope.page<=5}">
<c:forEach var="i" begin="2" end="${requestScope.page}">
<td><a href="ViewServlet?currentPage=${i}">[${i }]</a> </td>
</c:forEach>
</c:when>
<c:otherwise>
...
<c:forEach var="i" begin="${requestScope.page-3}"
end="${requestScope.page}">
<td><a href="javascript:goPage(${i})">[${i }]</a> </td>
</c:forEach>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${requestScope.page>=totalPage-4
|| totalPage-4<=0}">
<c:forEach var="i" begin="${requestScope.page+1}"
end="${totalPage}">
<td><a href="javascript:goPage(${i})">[${i }]</a> </td>
</c:forEach>
</c:when>
<c:otherwise>
<c:forEach var="i" begin="${requestScope.page+1}"
end="${requestScope.currentPage+3}">
<td><a href="javascript:goPage(${i})">[${i }]</a> </td>
</c:forEach>
...
<td><a href="javascript:goPage(${totalPage})">
[${totalPage}]</a> </td>
</c:otherwise>
</c:choose>
</c:if>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。