日期:2014-05-18  浏览次数:20673 次

奇怪:jsp 分页问题
问题在于,首页显示正确,但是后面的下一页等均不对???
javabean代码:
package   spage;
import   java.sql.*;

public   class   ShowPage   {
public   String   fluxPage(ResultSet   rs,int   p,int   size){
String   str= " ";
try{
for(int   k=0;k <(p-1)*size;k++){
rs.next();
}
}
catch(SQLException   e){
e.printStackTrace();
  }
        str= " <tr> <th> "+ "业务类别 "+ " </th> <th> "+ "用户ID "+ " </th> <th> "+ "居民区ID "+ " </th> <th> "+ "用水量 "+ " </th> <th> "+ "日期 "+ " </th> </tr> ";
        for(int   iPage=0;iPage <size;iPage++){
        str+=fluxRow(rs,iPage,size);
        try{
        if(!rs.next())break;
        }
        catch(Exception   e){
        e.printStackTrace();
        }
        }
return   str;
}
public   static   String   fluxRow(ResultSet   rs,int   i,int   size){
String   temp= " <tr> <td> 个人用户 </td> ";
     
try{
temp+= " <td> "+Integer.parseInt(rs.getString( "userid "))+ " </td> ";
temp+= " <td> "+Integer.parseInt(rs.getString( "resideid "))+ " </td> ";
temp+= " <td> "+Integer.parseInt(rs.getString( "flux "))+ " </td> ";
temp+= " <td> "+rs.getString( "date ")+ " </td> </tr> ";
}
catch(Exception   e){
e.printStackTrace();
}
return   temp;
}
}
jsp代码:
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "   "http://www.w3.org/TR/html4/loose.dtd ">

<%@   page   language= "java "   contentType= "text/html;   charset=gb2312 "%>
<%@   page   import= "java.sql.* "   %>
<%@   page   import= "java.io.* "   %>
<jsp:include   page= "top.jsp "   flush= "true "   />

<jsp:useBean   id= "conn "   class= "dbBean.DbBean "   scope= "session "/>
<jsp:useBean   id= "sp "   class= "spage.ShowPage "   scope= "session "/>
<jsp:setProperty   name= "conn "   property= "url "   value= "jdbc:mysql://localhost/test "/>

<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=ISO-8859-1 ">
<title> 用户用水信息 </title>
</head>
<body>
<center>
<div   id= "wrapper ">
<form   action= "fluxlist.jsp "   method= "get "width= "80% ">