分页
1.先将所有的页显示出来 c:遍历
<c:forEach begin="1" end="${pb.totalPage}" var="n" >
判断是否是当前页,是当前页 设置为激活状态,页码每页超链接,非当前页,设置超链接
2.判断是否是首页 是首页。上一页不可点。不是,设置超链接跳转到上一页
3.判断是否是尾页 是尾页。下一页不可点。不是,设置超链接跳转到下一页
<!--分页 -->
<div style="width: 380px; margin: 0 auto; margin-top: 50px;">
<ul class="pagination" style="text-align: center; margin-top: 10px;">
<!-- 判断是否是首页 -->
<c:if test="${pb.currPage == 1 }">
<li class="disabled"><a href="javascript:void(0)"
aria-label="Previous"><span aria-hidden="true">«</span></a></li>
</c:if>
<c:if test="${pb.currPage != 1 }">
<li><a
href="${pageContext.request.contextPath }/product?method=findByPage&cid=${param.cid}&currPage=${pb.currPage-1 }"
aria-label="Previous"><span aria-hidden="true">«</span></a></li>
</c:if>
<!-- 展示所有页码 按照百度网页前五后四风格展示 -->
<c:forEach begin="${pb.currPage-5>0?pb.currPage:1 }"
end="${pb.currPage+4>pb.totalPage?pb.totalPage:pb.currPage+4 }"
var="n">
<!-- 判断是否是当前页 -->
<c:if test="${pb.currPage == n }">
<li class="active"><a href="javascript:void(0)">${n }</a></li>
</c:if>
<c:if test="${pb.currPage != n }">
<li><a
href="${pageContext.request.contextPath }/product?method=findByPage&cid=${param.cid}&currPage=${n }">${n }</a></li>
</c:if>
</c:forEach>
<!-- 判断是否是最后一页 -->
<c:if test="${pb.currPage == pb.totalPage }">
<li class="disabled"><a href="javacript:void(0)"
aria-label="Next"><span aria-hidden="true">»</span></a></li>
</c:if>
<c:if test="${pb.currPage != pb.totalPage }">
<li><a
href="${pageContext.request.contextPath }/product?method=findByPage&cid=${param.cid}&currPage=${pb.currPage+1 }"
aria-label="Next"><span aria-hidden="true">»</span></a></li>
</c:if>
</ul>
</div>
<!-- 分页结束======================= -->
浙公网安备 33010602011771号