分页前端显示:
<%
int i = 1;
int numPerPage = 14;//每页数据量
String pages = request.getParameter("page") ;
int currentPage = 1;
currentPage = (pages==null)?1:Integer.parseInt(pages);
sql = "select count(*) from tables";
ResultSet rs = DBLink.executeQuery(sql) ;
while(rs.next()){
i = rs.getInt(1);
}
int yeshu = 1;//页数
yeshu = (i%numPerPage==0)?(i/numPerPage):(i/numPerPage+1);
int nextPage ;
int upPage;
nextPage = currentPage + 1;
if (nextPage>=yeshu){
nextPage=yeshu;
}
upPage = currentPage-1;
if (upPage<=1){
upPage=1;
}
rs.close();
sql="select * from tables";
rs=DBLink.executeQuery(sql);
i=0;
while((i<numPerPage*(currentPage-1))&&rs.next()){
i++;
}
%>
//输出内容
//输出翻页连接
合计:<%=currentPage%>/<%=yeshu%><a href="List.jsp?page=1">第一页</a><a href="List.jsp?page=<%=upPage%>">上一页</a>
<%
for(int j=1;j<=yeshu;j++){
if(currentPage!=j){
%>
<a href="list.jsp?page=<%=j%>">[<%=j%>]</a>
<%
}else{
out.println(j);
}
}
%>
<a href="List.jsp?page=<%&