....i=0;
while(i<(intPageSize*(intpage-1)){
i++;
sqlRst.next();
}
i=0;
boolean sign=true;
while(i<intPageSize &&sign){
      %>
<tr>
   <td><%=sqlRst.getString("username")%></td>
   <td><%=sqlRst.getString("phonecode")%></td>
</tr>
      <%
      sign=sqlRst.next();
      i++;
   }
....

解决方案 »

  1.   

    package hzdq.fdjc.Common;import java.sql.*;
    import java.util.*;/**
     * Title:分页
     * Description:
     * Copyright:    Copyright (c) 2004
     * Company:
     * author:颜喜班
     * @version 1.0
     */
    public class SplitPager
    {
      /*
       * _sql_str:传入的sql语句
       * _total_records: 总记录数目
       * _pageSize: 每页显示的记录数目
       * _page: 所分的逻辑页数
       */
    private Connection con=null;
    private Statement stmt=null;
    private ResultSet rs=null;
    private ResultSetMetaData rsmd=null;
    private String _sql_str;
    private int _total_records;
    private int _pages;
    private int _pagesize;
    public void setConnection(Connection con)
    {
    this.con=con;
    if (this.con == null)
                System.out.println("Failure to get a connection!");
    else
    System.out.println("Success to get a connection!");
    }
    public void initialize(String sqlStr,int pageSize)
    {
    this._sql_str=sqlStr;
    this._pagesize=pageSize;
    try{  
    stmt=this.con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);  
                    rs=stmt.executeQuery(this._sql_str); 
    rsmd=rs.getMetaData();
    if (rs!=null)
    {
    rs.last();
    this._total_records = rs.getRow();
    rs.first();
    this._pages = (this._total_records - 1) / this._pagesize + 1;

    }  
               catch(SQLException  e){System.out.println(e.toString()); } 
    }
    public  Vector  getPage(int ipage){ 
              Vector  vData=new  Vector();
              int  n=ipage;  
              int  m=0;  
              m=(n-1)*this._pagesize+1;  
      try{
    if (rs!=null)
    {
    rs.absolute(m);
    for(int i=0;i<this._pagesize;i++){
    String[] sData=new String[rsmd.getColumnCount()];
    for(int j=0;j<rsmd.getColumnCount();j++)
    {
    sData[j]=rs.getString(j+1);
    }
    if (sData==null)
    {
    break;
    }
    vData.addElement(sData);
    rs.next();

    }            
                    rs.close();  
        stmt.close(); 
                    }  
               catch(SQLException  e){System.out.println(e.toString()); } 
               return  vData;  
    }  
    public int getPages()
        {
            return this._pages;
        }
    public int getTotalRecords()
        {
            return this._total_records;
        }}
      

  2.   

    to yanxibang
    请问在jsp中是怎样调用这个bean的,能否贴出来。
      

  3.   

    /**  格式[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [>>]  
       * 按照页码范围分页的方法
       * @param jspName 要进行分页的jsp文件名
       * @param pageNo 当前页
       * @param totalPage 总页数
       * @param pageSize 放置的页数
       */
      public static String getPageRange(String jspName,int pageNo,int totalPage,int pageSize)
      {
        int startPageNo=pageNo/pageSize*pageSize;
        int endPageNo=startPageNo+pageSize;
        StringBuffer buf=new StringBuffer();
        buf.append("<p align=center>");
        if(startPageNo>0)
          buf.append("<a href=\""+jspName+"?pageNo="+(startPageNo-pageSize+1)+"\">[<<<]</a>");
        for(int i=1;i<=pageSize;++i)
          buf.append("<a href=\""+jspName+"?pageNo="+(startPageNo+i)+"\">["+(startPageNo+i)+"]</a>&nbsp;");
        if(endPageNo!=totalPage)
          buf.append("<a href=\""+jspName+"?pageNo="+(endPageNo)+"\">[>>>]</a>");
        buf.append("</p>");
        buf.append("<p align=center>第"+pageNo+"页&nbsp;共"+totalPage+"页</p>");
        return buf.toString();
      }