如何在分页列表中获取有限的页码以显示项目列表?
<c:if test="${paging.pageCount > 1}">
<c:if test="${not empty searchkey}">
<c:set var="pagingpath1" value="&key=${searchkey}&value=${searchvalue}" />
</c:if>
<div style=" background:#f5f5f5; border:1px solid #dedede; height:30px; width:985px; margin:20px auto">
<div class="pagDiv_1"><a>Results:<span><c:out value="${ paging.page }"> - </c:out> - <c:out value="${ paging.pageCount }"></c:out> ( total: <c:out value="${ paging.count }"></c:out> )</span></a></div>
<div class="page-nav">
<a>Pages:</a>
<c:choose>
<c:when test="${paging.orderStatus}">
<c:set var="pagingpath" value="&order=${paging.order}&dir=${paging.direction}">
</c:set>
</c:when>
<c:otherwise><c:set var="pagingpath" value=""></c:set></c:otherwise>
</c:choose>
<a class=lftarrow href="#">Previous ◄</a>
<c:forEach var="pid" varStatus="status" begin="1" end="${paging.pageCount}" step="1">
<c:choose>
<c:when test="${pid == paging.page}"><span class="cur-page"><b>${ pid }</b></span><label>|</label></c:when>
<c:otherwise><a class="page" href="consultant_list.htm?p=${pid}${pagingpath1}&selectiontype=${selectiontype1}&searchtext=${textbox1}">${ pid }</a><label>|</label></c:otherwise>
</c:choose>
</c:forEach>
<a class=lftarrow href="#">► Next</a>
</div>
</div>
</c:if>
所附图像包含我正在其中工作的列表页面。
该代码片段用于在页脚中显示分页。
如何使 4 个页码一次可见,并且单击“下一步”时其他页面必须可见?
<c:if test="${paging.pageCount > 1}">
<c:if test="${not empty searchkey}">
<c:set var="pagingpath1" value="&key=${searchkey}&value=${searchvalue}" />
</c:if>
<div style=" background:#f5f5f5; border:1px solid #dedede; height:30px; width:985px; margin:20px auto">
<div class="pagDiv_1"><a>Results:<span><c:out value="${ paging.page }"> - </c:out> - <c:out value="${ paging.pageCount }"></c:out> ( total: <c:out value="${ paging.count }"></c:out> )</span></a></div>
<div class="page-nav">
<a>Pages:</a>
<c:choose>
<c:when test="${paging.orderStatus}">
<c:set var="pagingpath" value="&order=${paging.order}&dir=${paging.direction}">
</c:set>
</c:when>
<c:otherwise><c:set var="pagingpath" value=""></c:set></c:otherwise>
</c:choose>
<a class=lftarrow href="#">Previous ◄</a>
<c:forEach var="pid" varStatus="status" begin="1" end="${paging.pageCount}" step="1">
<c:choose>
<c:when test="${pid == paging.page}"><span class="cur-page"><b>${ pid }</b></span><label>|</label></c:when>
<c:otherwise><a class="page" href="consultant_list.htm?p=${pid}${pagingpath1}&selectiontype=${selectiontype1}&searchtext=${textbox1}">${ pid }</a><label>|</label></c:otherwise>
</c:choose>
</c:forEach>
<a class=lftarrow href="#">► Next</a>
</div>
</div>
</c:if>
The image attached has the listing page in which I am working .
The code snippet is to display the pagenation in the footer.
How to make only say 4 page numbers visible at once and on click of "Next" the other pages must be visible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以为此创建一个标签,它只能显示相关页面(当前页面以及开始和最后一页周围很少),它可以在多个地方使用,并且也将是更清晰的方法。
您可以创建一个标签,它将接受以下参数:
在此标签中,您可以添加此代码以仅显示少数页码(例如 10)以及第一个和第二个页码。最后一页链接。现在这个东西可以用作一个组件,可以在应用程序的各个地方使用。
You can create a Tag for this which can display only relevant pages (few around the current page and start & last page), which can be used at multiple places and will be cleaner approach as well.
You can create a tag, which will accept these parameters:
In this tag you can add this code to show only few page numbers (say 10) with first & last page link. Now this thing can be used as a component which can be used in various places of your application.
DisplayTag 是一个很棒的小库,可以让您轻松完成想做的事情。
http://www.displaytag.org/ 1.2/
或者,如果数据集的大小(字节)不是很大,那么以下 Jquery 库也很酷:
http://datatables.net/
DisplayTag is a wonderful little library that makes what you want to do easy..
http://www.displaytag.org/1.2/
Alternatively, if the size of your dataset's aren't very large in size (bytes) the following Jquery library is also cool:
http://datatables.net/