• 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>&nbsp;</td>  
                                </c:forEach>  
                            </c:when>  
                            <c:otherwise>  
                                ...&nbsp;  
                                <c:forEach var="i" begin="${requestScope.page-3}"  
                                    end="${requestScope.page}">  
                                   <td><a href="javascript:goPage(${i})">[${i }]</a>&nbsp;</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>&nbsp;</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>&nbsp;</td>  
                                </c:forEach>  
                                ...&nbsp;  
                                <td><a href="javascript:goPage(${totalPage})">  
                                    [${totalPage}]</a>&nbsp;</td>
                            </c:otherwise>  
                        </c:choose>  
                    </c:if>

  • 相关阅读:
    CF1174D Ehab and the Expected XOR Problem
    CF1083B The Fair Nut and Strings
    CF1088D Ehab and another another xor problem
    CF1168A Increasing by Modulo
    CF1166C A Tale of Two Lands
    CF1142A The Beatles
    CF1105D Kilani and the Game
    【uva11248】网络扩容
    【sam复习】用sam实现后缀排序
    【Educational Codeforces Round 19】
  • 原文地址:https://www.cnblogs.com/ClodThunder/p/4154414.html
Copyright © 2020-2023  润新知