java bootstrap分页

时间:2024-01-13 15:22:32

样式如下

java bootstrap分页

datumMap.total总共多少页

datumMap.page第几页

    <nav class="pull-right">
<ul class="pagination">
<!-- 是否能点击前一页 -->
<c:choose>
<c:when test="${datumMap.page==1}">
<li class="disabled">
<a aria-label="Previous" href="javascript:void(0);">
<span aria-hidden="true">«</span>
</a>
</li>
</c:when>
<c:otherwise>
<li>
<a aria-label="Previous" href="${ctx_path}/datum/show_datum?page=${datumMap.page-1}">
<span aria-hidden="true">«</span>
</a>
</li>
</c:otherwise>
</c:choose>
<!-- 显示可以点击的页数 -->
<c:choose>
<c:when test="${datumMap.total<=5}">
<c:forEach var="p" begin="1" end="${datumMap.total}">
<li <c:if test="${datumMap.page==p}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=${p}">${p}</a></li>
</c:forEach>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${datumMap.page < 4 && datumMap.page > 0}"><!-- 1-3页 -->
<li <c:if test="${datumMap.page == 1}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=1">1</a></li>
<li <c:if test="${datumMap.page == 2}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=2">2</a></li>
<li <c:if test="${datumMap.page == 3}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=3">3</a></li>
<li <c:if test="${datumMap.page == 4}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=4">4</a></li>
<li><a href="javascript:void(0);" class="disabled">...</a></li>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.total}">${datumMap.total}</a></li>
</c:when>
<c:when test="${datumMap.page < datumMap.total-2}">
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.page-2}">${datumMap.page-2}</a></li>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.page-1}">${datumMap.page-1}</a></li>
<li class="active"><a href="${ctx_path}/datum/show_datum?page=${datumMap.page}">${datumMap.page}</a></li>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.page+1}">${datumMap.page+1}</a></li>
<li><a href="javascript:void(0);" class="disabled">...</a></li>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.total}">${datumMap.total}</a></li>
</c:when>
<c:otherwise>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.total-4}">${datumMap.total-4}</a></li>
<li><a href="${ctx_path}/datum/show_datum?page=${datumMap.total-3}">${datumMap.total-3}</a></li>
<li <c:if test="${datumMap.page==datumMap.total-2}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=${datumMap.total-2}">${datumMap.total-2}</a></li>
<li <c:if test="${datumMap.page==datumMap.total-1}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=${datumMap.total-1}">${datumMap.total-1}</a></li>
<li <c:if test="${datumMap.page==datumMap.total}">class="active"</c:if>><a href="${ctx_path}/datum/show_datum?page=${datumMap.total}">${datumMap.total}</a></li>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<!-- 是否能点击后一页 -->
<c:choose>
<c:when test="${datumMap.page==datumMap.total}">
<li class="disabled">
<a aria-label="Next" href="javascript:void(0);">
<span aria-hidden="true">»</span>
</a>
</li>
</c:when>
<c:otherwise>
<li>
<a aria-label="Next" href="${ctx_path}/datum/show_datum?page=${datumMap.page+1}">
<span aria-hidden="true">»</span>
</a>
</li>
</c:otherwise>
</c:choose>
</ul>
</nav>