ssh前台分页最好用list
ssh后台分页最好用hibernate
<body>
<table border="1" >
<tr>
<td>
ID
</td>
<td>
NAME
</td>
</tr>
<%
java.util.ArrayList list=(java.util.ArrayList)session.getAttribute("list");
//一共多少行
int totalcount=list.size();
//每页多少行
int perpage=5;
//一共多少页
int totalpage=0;
if(totalcount%perpage!=0){
totalpage=totalcount/perpage+1;
}else{
totalpage=totalcount/perpage;
}
//url传过来的变量的数值
int pagenum=1;
String pagem=request.getParameter("page");
if(pagem!="" && pagem!=null){
pagenum=Integer.parseInt(pagem);
if(pagenum>totalpage){
pagenum=totalpage;
}else if(pagenum<=1){
pagenum=1;
}
}else{
pagenum=1;
}
for(int i=(pagenum-1)*perpage;i<perpage*pagenum;i++){
com.zyy.dao.Info info=(com.zyy.dao.Info)list.get(i);
%>
<tr>
<td>
<%=info.getId() %>
</td>
<td>
<%=info.getName() %>
</td>
</tr>
<%}%>
</table>
<a href="fenye.jsp?page=<%=pagenum-1 %>" >上一页</a>
<a href="fenye.jsp?page=<%=pagenum+1 %>">下一页</a>
</body>