要的参数都传给下一页啊
比如 next.jsp?ID1=xx&ID2=xx
数据库里读出来,我放在ResultSet中,然后每一页放在ArrayList中,再显示出来

解决方案 »

  1.   

    分页,我一般是这么做的
    把数据库select出来的信息放在一个vector中然后现实1-10个,根据vector.size()出现“1 2 3 4“的分页链接
    2就显示11-20,依此类推vector可以放在session中。
      

  2.   

    <%@ page contentType="text/html; charset=gb2312"%>
    <%@ include file="/DataIni/DataOpen.jsp"%>
    <%@ include file="/ScriptLib/Init.jsp"%>
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css">
    </head><body>
    <%@ include file="/TemplateLib/Head.jsp"%>
    <br>
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="80%">
      <tr>
        <td width="10%" class="TdClass_Head">公文审批</td>
      </tr>
    </table>
    <script>
    function SelectCategory(select)
    {
    for(i=0;i<select.length;i++)
    {
    if(select.options[i].selected)
    {
    window.location.href="List.jsp?Category="+select.options[i].text+"&Page=1";
    }
    }
    }
    </script>
    <table border="0" cellpadding="0" cellspacing="0" width="80%">
      <tr>
        <td width="10%" class="TdClass_0">公文类别</td><td width="90%" class="TdClass_1">
          <select name="Category" size=1 style="width:80%" onchange="SelectCategory(this)">
    <option value="">--请选择--</option>      
    <%
    String strCategory;
    strCategory=request.getParameter("Category");
    if(strCategory==null)
    {
    strCategory="";
    }
    odbcQuery="select distinct Category from Doc";
    odbcRs=odbcStmt.executeQuery(odbcQuery);
    String Category;
    Category="";
    while(odbcRs.next())
    {
    Category=outStr((String)odbcRs.getString("Category"));
    %>                
            <option value="<%=Category%>" <%if(strCategory.equals(Category)){%>selected<%}else{%><%}%>><%=Category%></option>
    <%
    }
    odbcRs.close();
    %>
          </select>
          <input type="button" value="拟制" id="NewItem" name="NewItem" onclick="window.location.href='/System/Doc/New.jsp';">
        </td>
      </tr>
    </table><table border="0" cellpadding="0" cellspacing="0" width="80%">
    <%
    int Page;
    String strPage;
    strPage=request.getParameter("Page");
    if(strPage==null)
    {
    Page=1;
    }
    else
    {
    Page=java.lang.Integer.parseInt(strPage);
    }
    if(strCategory!=null)
    {
    odbcQuery="select * from Doc where Category='"+strCategory+"'";
    }
    else
    {
    odbcQuery="select * from Doc";
    }
    odbcRs_=odbcStmt_.executeQuery(odbcQuery);
    int RecordSum,PageSum,PageSize;
    RecordSum=0;
    PageSum=0;
    odbcRs_.last();
    RecordSum=odbcRs_.getRow();
    PageSize=10;
    PageSum=(RecordSum+PageSize-1)/PageSize;
    int iCount;
    if(Page>PageSum){Page=PageSum;}
    if(PageSum>0)
    {
    odbcRs_.absolute((Page-1)*PageSize+1);
    String Id,Subject,Author,History;
    iCount=0;
    while(iCount<PageSize&&!odbcRs_.isAfterLast())
    {
    Id=outStr((String)odbcRs_.getString("ID"));
    Subject=outStr((String)odbcRs_.getString("Subject"));
    Author=outStr((String)getUserName(odbcRs_.getString("Author")));
    History=outStr((String)odbcRs_.getString("History"));
    %>
    <script>
    function ShowBody(Id)
    {
    var hwnd=window.open('ShowBody.jsp?Id='+Id,'','');
    }
    </script>
      <tr>
        <td width="20%" class="TdClass_1">
          <a href="#" onclick="ShowBody('<%=Id%>')">主题:<%=Subject%>[作者:<%=Author%>(日期时间:<%=History%>)]</a>
          <a href="ModifyResult.jsp?Id=<%=Id%>">修改</a>
          <a href="DelResult.jsp?Id=<%=Id%>">删除</a>
        </td>
      </tr>
    <%
    odbcRs_.next();
    iCount++;
    }
    }
    odbcRs_.close();
    %>
    </table>            
    <table border="0" cellpadding="0" cellspacing="0" width="80%">
      <tr>
        <td width="25%" class="TdClass_Head"><%if(Page>1){%><a href="List.jsp?Category=<%=Category%>&Page=<%=Page-1%>">上一页</a><%}%></td>
        <td width="25%" class="TdClass_Head">记录<%=RecordSum%>条</td>
        <td width="25%" class="TdClass_Head">共有<%=PageSum%>页</td>
        <td width="25%" class="TdClass_Head"><%if(Page<PageSum){%><a href="List.jsp?Category=<%=Category%>&Page=<%=Page+1%>">下一页</a><%}%></td>
      </tr>
    </table></center>
    <%@ include file="/TemplateLib/Tail.jsp"%>
    <%@ include file="/DataIni/DataClose.jsp"%>
    </body></html>
      

  3.   

    使用<jsp:forward>是可以带参数的。
    例如:<jsp:forward page="newpage.jsp">
       <jsp:param name="parametername" value="parametervalue"/>
    </jsp:forward>另一种方法,就是把这些需要用到的信息保存在session中。
      

  4.   

    现在我把查询出的数据放到struts的ActionForm中了,这样就需要每翻一页都查数据库一次了,而且也可以不用传递查询字段了。
      

  5.   

    基本原理应该就时把查出的数据放到session中吧,不知会不会增加服务器的负担,我一直对jsp的session实现机制搞不明白,顺便问一下,session的数据是存到什么地方的,书上说session用cookie来实现,指的是把数据放到客户端的cookie里吗,在session中存放这么多数据会不会影响服务器性能。
      

  6.   

    可以用session啊,也可以佣隐藏表单或者地址传