您的位置:首页 > Web前端 > JavaScript

jstl 实现分页效果

2016-09-13 15:18 218 查看
代码部分

<div class="pagination center">
<b>共${page.pageCount}页</b>
<c:choose>
<c:when test="${page.currentPage+1 == 1}">
<a class="navlinks current">首页 </a>
<a class="pagebtn" style="font-size: 12px;color: #454545;background-color: #eee;font-weight: 600;text-transform: uppercase;padding: 7px 10px;border-radius: 3px;margin-left: 5px;margin-right:5px;"><上一页 </a>
</c:when>
<c:otherwise>
<a href='${pageContent.request.contextPath}/news?currentPage=0&type=${page.type}' class="navlinks">首页 </a>
<a href='${pageContent.request.contextPath}/news?currentPage=${page.currentPage-1}&type=${page.type}' class="navlinks pagebtn"style="margin-left: 5px;margin-right:5px"><上一页 </a>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${page.pageCount+1 <= 5}">
<c:forEach begin="1" end="${page.pageCount}" varStatus="s">
<c:choose>
<c:when test="${s.index == page.currentPage+1}">
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks current">${s.index}</a>
</c:when>
<c:otherwise>
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks">${s.index}</a>
</c:otherwise>
</c:choose>
</c:forEach>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${page.currentPage+1-1 > 2}">
<c:choose>
<c:when test="${page.currentPage+3 >= page.pageCount}">
<c:forEach begin="${page.pageCount-4}" end="${page.pageCount}" varStatus="s">
<c:choose>
<c:when test="${s.index == page.currentPage+1}">
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks current">${s.index}</a>
</c:when>
<c:otherwise>
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks">${s.index}</a>
</c:otherwise>
</c:choose>
</c:forEach>
</c:when>
<c:otherwise>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage-2}&type=${page.type}" class="navlinks">${page.currentPage+1-2}</a>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage-1}&type=${page.type}" class="navlinks">${page.currentPage+1-1}</a>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage}&type=${page.type}" class="navlinks current">${page.currentPage+1}</a>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage+1}&type=${page.type}" class="navlinks">${page.currentPage+1+1}</a>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage+1+1}&type=${page.type}" class="navlinks">${page.currentPage+1+2}</a>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<c:forEach end="5" begin="1" varStatus="s">
<c:choose>
<c:when test="${s.index == page.currentPage+1}">
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks current">${s.index}</a>
</c:when>
<c:otherwise>
<a href="${pageContent.request.contextPath}/news?currentPage=${s.index-1}&type=${page.type}" class="navlinks">${s.index}</a>
</c:otherwise>
</c:choose>
</c:forEach>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${page.currentPage+1 == page.pageCount}">
<a class="pagebtn"style="font-size: 12px;color: #454545;background-color: #eee;font-weight: 600;text-transform: uppercase;padding: 7px 10px;border-radius: 3px;"> 下一页></a>
<a class="navlinks current"> 末页</a>
</c:when>
<c:otherwise>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.currentPage+1}&type=${page.type}" class="navlinks pagebtn"> 下一页></a>
<a href="${pageContent.request.contextPath}/news?currentPage=${page.pageCount-1}&type=${page.type}" class="navlinks"> 末页</a>
</c:otherwise>
</c:choose>
</div>
效果实现

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  分页 jstl