<% ... @ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <% ... String currentPage=request.getParameter("currentPage"); String pages=request.getParameter("pages"); %> < div id ="show" > </ div > < script > ... var currentPage=<%=currentPage%>; var pages=<%=pages%>; var group; if(currentPage%10==0)...{ group=Math.floor(currentPage/10); }else...{ group=Math.floor(currentPage/10+1); } function showPage(currentGroup)...{ var showStr=""; var groups; if(pages%10==0)...{ groups=Math.floor(pages/10); }else...{ groups=Math.floor(pages/10+1); } //向前滚动 if(currentGroup<=1)...{ showStr=showStr+"<<"; }else...{ showStr=showStr+"<a href='javascript:showPage("+(currentGroup-1)+")'><<</a>"; } if(pages<=10)...{ for(var i=1;i<=pages;i++)...{ if(i==currentPage)...{ showStr=showStr+" [<a href='a.jsp?currentPage="+i+"&pages=<%=pages%>'>"+i+"</a>] "; }else...{ showStr=showStr+" <a href='a.jsp?currentPage="+i+"&pages=<%=pages%>'>"+i+"</a> "; } } }else if((pages-currentPage)<=pages%10 || (currentGroup==groups && pages%10!=0))...{ var num; for(var i=1;i<=pages%10;i++)...{ num=(currentGroup-1)*10+i; if(num==currentPage)...{ showStr=showStr+" [<a href='a.jsp?currentPage="+num+"&pages=<%=pages%>'>"+num+"</a>] "; }else...{ showStr=showStr+" <a href='a.jsp?currentPage="+num+"&pages=<%=pages%>'>"+num+"</a> "; } } }else...{ var num; for(var i=1;i<=10;i++)...{ num=(currentGroup-1)*10+i; if(num==currentPage)...{ showStr=showStr+" [<a href='a.jsp?currentPage="+num+"&pages=<%=pages%>'>"+num+"</a>] "; }else...{ showStr=showStr+" <a href='a.jsp?currentPage="+num+"&pages=<%=pages%>'>"+num+"</a> "; } } } //向后滚动 if(currentGroup>=groups)...{ showStr=showStr+">>"; }else...{ showStr=showStr+"<a href='javascript:showPage("+(currentGroup+1)+")'>>></a>"; } document.getElementById("show").innerHTML=showStr; } showPage(group); </ script >