http://expert.csdn.net/Expert/topic/2188/2188794.xml?temp=.442425
欢迎参考一下。

解决方案 »

  1.   

    这个确实很麻烦阿。
    特别是数据集很大的时候,都放到session里。服务器会挂掉的。我觉得每次取50--100条纪录,保存到session中。
      

  2.   

    kypfos(深圳不是我的家) 
      呵呵,csdn上的老鸟呀。眼熟的很,希望能有一天和你谈经论道。现在想知道你说的:
    “页面分页多类呀,查询分页,或者是存储过程分页吧。”的具体所指。可否给个详细说明呢。
      

  3.   

    jsptags.com提供了一个免费分页的taglib,,,用了,,,感觉很不错。。
    没有必要自己写一个类,,,把主要精力放在编写EJB或javabean中更好。。:)
      

  4.   

    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;
        }}
      

  5.   

    好东西当然要分享啊!看我的:经典分页程序
    jsp+javaBeanhttp://www.52free.com/bbs/index.php?act=ST&f=8&t=148&st=0#entry298如果数据库不同只需修改javaBean中的驱动即可,页面显示数可以自己控制。