<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ include file="/decorators/includes/taglibs.jsp"%> <!-- ectable样式的分页 --> <script type="text/javascript"> <!-- function toPage(pageNum){ $("#pageNum").val(pageNum); $("#qform").submit(); } function goPage(){ if(isNaN($("#_page_No_").val())){ alert("页码不正确"); return; } toPage($("#_page_No_").val()-1); } //--> </script> <table border="0" cellspacing="0" cellpadding="0" class="tableRegion" width="100%"> <tbody> <tr style="padding: 0px;"> <td style="border: 0px solid #CCC;"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td class="statusBar" align="center"> 共 <span style="color: red">${totalCount }</span> 条记录, 当前显示 <span style="color: red">${totalCount==0?0:pageSize*(pageNum-1)+1 }</span> 到 <span style="color: red"> <c:choose> <c:when test="${pageSize*pageNum > totalCount }">${totalCount }</c:when> <c:otherwise>${pageSize*pageNum }</c:otherwise> </c:choose> </span> 条 <c:if test="${totalPage > 1 }"> <c:choose> <c:when test="${pageNum > 1 }"> <span onclick="toPage(${pageNum - 2 })" style="margin: 4px;cursor:pointer;" title="上一页">上一页</span> </c:when> <c:otherwise> <span style="margin: 4px;">上一页</span> </c:otherwise> </c:choose> <!-- 显示中间的页数 --> <c:choose> <c:when test="${totalPage <= 10}"> <c:forEach var="indexNo" begin="1" end="${totalPage}"> <c:choose> <c:when test="${pageNum == indexNo}"> <span style="margin: 4px;color:red">${indexNo }</span> </c:when> <c:otherwise> <span onclick="toPage(${indexNo-1 })" style="margin: 4px;cursor:pointer;">${indexNo }</span> </c:otherwise> </c:choose> </c:forEach> </c:when> <c:when test="${pageNum < 10 && totalPage > 10}"> <c:forEach var="indexNo" begin="1" end="10"> <c:choose> <c:when test="${pageNum == indexNo}"> <span style="margin: 4px;color:red">${indexNo }</span> </c:when> <c:otherwise> <span onclick="toPage(${indexNo-1 })" style="margin: 4px;cursor:pointer;">${indexNo }</span> </c:otherwise> </c:choose> </c:forEach> <span style="margin: 4px;color:red">...</span> <span onclick="toPage(${totalPage-1})" style="margin: 4px;cursor:pointer;">${totalPage}</span> </c:when> <c:when test="${pageNum >= 10 && pageNum < totalPage-1}"> <span onclick="toPage(0)" style="margin: 4px;cursor:pointer;">1</span> <span style="margin: 4px;color:red">...</span> <c:forEach var="indexNo" begin="${pageNum-7 }" end="${pageNum+2 }"> <c:choose> <c:when test="${pageNum == indexNo}"> <span style="margin: 4px;color:red">${indexNo }</span> </c:when> <c:otherwise> <span onclick="toPage(${indexNo-1 })" style="margin: 4px;cursor:pointer;">${indexNo }</span> </c:otherwise> </c:choose> </c:forEach> <c:if test="${(pageNum+2) < totalPage }"> <span style="margin: 4px;color:red">...</span> <span onclick="toPage(${totalPage-1})" style="margin: 4px;cursor:pointer;">${totalPage}</span> </c:if> </c:when> <c:otherwise> <span onclick="toPage(0)" style="margin: 4px;cursor:pointer;">1</span> <span style="margin: 4px;color:red">...</span> <c:forEach var="indexNo" begin="${totalPage-9 }" end="${totalPage }"> <c:choose> <c:when test="${pageNum == indexNo}"> <span style="margin: 4px;color:red">${indexNo }</span> </c:when> <c:otherwise> <span onclick="toPage(${indexNo-1 })" style="margin: 4px;cursor:pointer;">${indexNo }</span> </c:otherwise> </c:choose> </c:forEach> </c:otherwise> </c:choose> <!-- 显示中间的页数 结束 --> <c:choose> <c:when test="${totalPage > 1 && pageNum < totalPage}"> <span onclick="toPage(${pageNum })" style="margin: 4px;cursor:pointer;" title="下一页">下一页</span> </c:when> <c:otherwise> <span style="margin: 4px;">下一页</span> </c:otherwise> </c:choose> <input type="text" style="width: 20px; height: 16px; margin-right: 4px;" id="_page_No_" value="${pageNum }"> <button onclick="goPage()" style="height: 20px;">GO</button> </c:if> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>
效果如下: