int count=0;             //记录记数
int currentPage=page;    //当前页,传进来的
int pageRecordCount=10;  //每页记录数;Collection msg = MsgBean.getSomeMsg(UserID);
Iterator it=msg.iterator();
while(it.hasNext())
{
     //是否在当前页内
     if( count>= curentPage*pageRecordCount && count< (curentPage+1)*pageRecordCount )
     {
         Msg rs=(Msg)it.next();
         out.print(rs.getMsgContent());
     }
     count++;
 }---------
未作调试,仅供参考

解决方案 »

  1.   

    **********************
    <%@ page language="java" import="java.util.*,java.sql.*" %>
    <%@ page contentType="text/html;charset=gb2312"%>
    <jsp:useBean id="cn" scope="page" class="myConnection.Conn" /><!--引用数据库操作的bean,自己完成,这里不再赘述-->
    <%
    int curpage=1;//当前页
    int page_record=20;//每页显示的记录数
    //用下面的方法(sql查询完成,速度快)
    curpage=Integer.parseInt(request.getParameter("page"));//获取传递的值,需要显示的页
    ResultSet rs=cn.rsexecuteQuery("select top "+page_record+" * from tablename where id not in (select top "+(curpage*page_record)+" id from tablename order by id desc) order by id desc");
    //本查询语句得到的是所要显示的1000页的20条记录,大致思路为——子查询排除需要显示的记录前的所有记录,父查询则对余下的记录进行降序排列
    while(rs.next) {
    out.println(rs.getInt("id").toString());
    }
    rs.close();
    %>
      

  2.   

    没有其他办法了?? >o<
      

  3.   

    http://blog.csdn.net/treeroot/archive/2004/10/01/122827.aspx
      

  4.   

    我用的也是这种分页方法,感觉比以前那种传统方法简单ResultSet rs=cn.rsexecuteQuery("select top "+page_record+" * from tablename where id not in (select top "+(curpage*page_record)+" id from tablename order by id desc) order by id desc");
      

  5.   

    把需要显示的集合转换成list类型
      

  6.   

    再用struts tag 的bean tag 就能很好的搞定,具体自己琢磨区