标签:
int pcount = r3d.pager.getPageCount(); int curpage = r3d.pager.getPageNow(); if (pcount > 1) {//显示超链接 //上一页 if (curpage != 1) { out.println("<a href=index.jsp?pageNow=" + (curpage - 1) + ">上一页</a>"); out.println("<a href=index.jsp?pageNow=1>[1]</a>"); } else out.println(" 1 "); int stap = curpage - 2; int endp = curpage + 2; if (endp > pcount - 1) stap -= (endp - pcount + 1); if (stap < 2) { endp += (2 - stap); stap = 2; } int i = stap; if (i > 2) { out.println("..."); } while (i <= endp && i <= pcount) { if (i == curpage) out.println(" " + i + " "); else out.println("<a href=index.jsp?pageNow=" + i + ">[" + i + "]</a>"); i++; } if (i < pcount) { out.println("..."); out.println("<a href=index.jsp?pageNow=" + pcount + ">[" + pcount + "]</a>"); } //下一页 if (curpage < pcount) { out.println("<a href=index.jsp?pageNow=" + (curpage + 1) + ">下一页</a>"); } }
标签:
原文地址:http://www.cnblogs.com/dashi/p/4316027.html