我的要实现的目标:要显示的话要先输入“客户名称”,然后输出第一页,然后可以自由跳转到指定页。单分页显示我会做,单按“客户名称”查询我会做,搞到一起我就不会了!!!!
现在我把这两个弄到一起了,结果是输入“客户名称 ”的时候可以显示第一页,当跳转页时就什么都显示不出来了,跟刚进到页面时一样。
第一次进入地址栏:http://localhost:8080/bbb/fenye1.jsp
输入客户“dontian"时:http://localhost:8080/bbb/fenye1.jsp?h_customer=dontian
输入第N页时http://localhost:8080/bbb/fenye1.jsp?page=1
我感觉地址栏最起码“?”后边既有page= 又有h_customer=才对啊!
求救!!!!!!!!!

解决方案 »

  1.   

    网上有现成的代码实现
    上google上找找估计问题是你没有把一些总页面数、当前页数、查询条件等等从第一个页面传到后面
      

  2.   

    输入客户“dontian"时:http://localhost:8080/bbb/fenye1.jsp?h_customer=dontian
    输入第N页时http://localhost:8080/bbb/fenye1.jsp?page=1
    不好给你源码.
    思路如下:fenye1.jsp?h_customer=..&page=1
    h_customer=...更加用户的名称从数据库搜索出结果放到ArrayList中,,
    然后根据page截取记录集的内容.
      

  3.   

    不太明白你说的page,能解释下吗 ?我用的分页基本上是借鉴书上的做法,它用了page,我不懂,而且在写页数连接的时候还有pages,不知道是笔误还是怎么回事
      

  4.   

    还有我屏蔽输入参数的时候,为什么点最后一页的连接,就报错?说是非法的游标状态
    我干脆把代码贴上咯:
    1。这是没有屏蔽输入参数的代码
    -----------------------------------------------------------------------------------------
    <%@ page contentType="text/html;charset=gb2312"language="java"%>
    <%@ page import="java.sql.*"%>
    <jsp:useBean id="connDbBean"scope="session"class="a.conn"/><%int i=0,intPage,intPageCount,intPageSize,intRowCount,intGetPage;%><%String strPage="";%>
    <%intPageSize=20;%>
    <%double sum_money=0;%>
    <%String customer_name=request.getParameter("h_customer");%><%String strSql="select customers.name,orders.idOrder,description,quantity,unitPrice*quantity from orderDetails ,products,orders,customers  where orderDetails.idProduct=products.idProduct and orders.idCustomer=customers.idcustomer and orders.idOrder=orderDetails.idOrder and customers.name='"+customer_name+"'";%>
    <%
      strPage=request.getParameter("intGetPage");
      if(strPage==null){
      intPage=1;
      }
      else{
      intPage=Integer.parseInt(strPage);
      if(intPage<1)
      intPage=1;
      }%><%ResultSet RS_result=connDbBean.executeQuery(strSql);
    RS_result.last();
    intRowCount=RS_result.getRow();%>
    <%if(intRowCount%intPageSize==0)
    intPageCount=(intRowCount/intPageSize);
    else 
    intPageCount=(intRowCount/intPageSize+1);
    %>
    <%if(intPage>intPageCount)
    intPage=intPageCount;%>
     <HTML>
    <HEAD>
    <TITLE>客户销售报告</TITLE>
    </HEAD>
    <BODY bgcolor=cyan><Size=1>
    <BR><BR>
    <h2 align="center">客户销售报告</h2>
    <form><p><div align="center">请输入客户名称:
    <input name="h_customer"type="text"class="text"size="10">
    <input name="submit"type="submit"class="file"value="查询"></div></p></form><DIV Align="center">
       <table width="75%"border="1">
        <tr>
        <td width="30%">
      <div align="center"><font><b>客户</b></font></div>
     </td>
     <td width="10%">
      <div align="center"><font><b>定单</b></font></div>
     </td>
     <td width="30%">
      <div align="center"><font><b>购买货品</b></font></div>
     </td>
     <td width="10%">
      <div align="center"><font><b>数量</b></font></div>
     </td>
     <td width="20%">
      <div align="center"><font><b>金额</b></font></div>
     </td>
     
    </tr>
      
    <%String custo="";
    long idor=0;
    String dscr="";
    long quant=0;
    double money=0;%><%if(intPageCount>0){
    RS_result.absolute((intPage-1)*intPageSize+1);
    i=0;while(i<intPageSize){
    custo=RS_result.getString(1);
      idor=RS_result.getLong(2);
      dscr=RS_result.getString(3);
      quant=RS_result.getLong(4);
      money=RS_result.getDouble(5);
      
    %>  <TR>
      <TD width="25%"><div align="center"><%=custo%></div></TD>
       <TD width="25%"><div align="center"><%=idor%></div></TD>
       <TD width="25%"><div align="center"><%=dscr%></div></TD>
       <TD width="25%"><div align="center"><%=quant%></div></TD> 
        <TD width="25%"><div align="center"><%=money%></div></TD>
        
      </TR>
      <%RS_result.next();
      i++;
      
      
      
       }
    }  
      %>
    </table>  
    <br><br><br>  
    第<%=intPage%>页  共<%=intPageCount%>页
    <%if(intPage==1){%>
    <a href="fenye1.jsp?page=1">第一页</a><%}%>
    <%if(intPage<intPageCount){%>
    <a href="fenye1.jsp?page=<%=intPage+1%>">下一页</a><%}%>
    <%if(intPage>1){%>
    <a href="fenye1.jsp?page=<%=intPage-1%>">上一页</a><%}%>
    <%if(intPage!=intPageCount & intPageCount!=0){%>
    <a href="fenye1.jsp?page=<%=intPageCount%>">最后一页</a><%}%>
    <!--<form>请输入您要查看的页码:
    <input name="intGetPage"type="text"class="text"size="10">
    <input name="submit_go"type="submit"class="file"value="go"></form>-->
    <%RS_result.close();%>
    </div>
    </BODY>
    </HTML>-----------------------------------------------------------------------------------------
    2。这是屏蔽输入参数后的代码
    ------------------------------------------------------------------------------
    <%@ page contentType="text/html;charset=gb2312"language="java"%>
    <%@ page import="java.sql.*"%>
    <jsp:useBean id="connDbBean"scope="session"class="a.conn"/><%int i=0,intPage,intPageCount,intPageSize,intRowCount,intGetPage;%><%String strPage="";%>
    <%intPageSize=20;%>
    <%double sum_money=0;%>
    <%//String customer_name=request.getParameter("h_customer");%><%String strSql="select customers.name,orders.idOrder,description,quantity,unitPrice*quantity from orderDetails ,products,orders,customers  where orderDetails.idProduct=products.idProduct and orders.idCustomer=customers.idcustomer and orders.idOrder=orderDetails.idOrder";%>
    <%
      strPage=request.getParameter("page");
      if(strPage==null){
      intPage=1;
      }
      else{
      intPage=Integer.parseInt(strPage);
      if(intPage<1)
      intPage=1;
      }%><%ResultSet RS_result=connDbBean.executeQuery(strSql);
    RS_result.last();
    intRowCount=RS_result.getRow();%>
    <%if(intRowCount%intPageSize==0)
    intPageCount=(intRowCount/intPageSize);
    else 
    intPageCount=(intRowCount/intPageSize+1);
    %>
    <%if(intPage>intPageCount)
    intPage=intPageCount;%>
     <HTML>
    <HEAD>
    <TITLE>客户销售报告</TITLE>
    </HEAD>
    <BODY bgcolor=cyan><Size=1>
    <BR><BR><h2 align="center">客户销售报告</h2>
    <!--
    <form><p><div align="center">请输入客户名称:
    <input name="h_customer"type="text"class="text"size="10">
    <input name="submit"type="submit"class="file"value="查询"></div></p></form>--><DIV Align="center">
       <table width="75%"border="1">
        <tr>
        <td width="30%">
      <div align="center"><font><b>客户</b></font></div>
     </td>
     <td width="10%">
      <div align="center"><font><b>定单</b></font></div>
     </td>
     <td width="30%">
      <div align="center"><font><b>购买货品</b></font></div>
     </td>
     <td width="10%">
      <div align="center"><font><b>数量</b></font></div>
     </td>
     <td width="20%">
      <div align="center"><font><b>金额</b></font></div>
     </td>
     
    </tr>
      
    <%String custo="";
    long idor=0;
    String dscr="";
    long quant=0;
    double money=0;%><%if(intPageCount>0){
    RS_result.absolute((intPage-1)*intPageSize+1);
    i=0;while(i<intPageSize){
    custo=RS_result.getString(1);
      idor=RS_result.getLong(2);
      dscr=RS_result.getString(3);
      quant=RS_result.getLong(4);
      money=RS_result.getDouble(5);
      
    %>  <TR>
      <TD width="25%"><div align="center"><%=custo%></div></TD>
       <TD width="25%"><div align="center"><%=idor%></div></TD>
       <TD width="25%"><div align="center"><%=dscr%></div></TD>
       <TD width="25%"><div align="center"><%=quant%></div></TD> 
        <TD width="25%"><div align="center"><%=money%></div></TD>
        
      </TR>
      <%RS_result.next();
      i++;
      
      
      
       }
    }  
      %>
    </table>  
    <br><br><br>  
    第<%=intPage%>页  共<%=intPageCount%>页
    <%if(intPage==1){%>
    <a href="fenye1.jsp?pages=1">第一页</a><%}%>
    <%if(intPage>1){%>
    <a href="fenye1.jsp?page=<%=intPage-1%>">上一页</a><%}%><%if(intPage<intPageCount){%>
    <a href="fenye1.jsp?page=<%=intPage+1%>">下一页</a><%}%>
    <%if(intPage==intPageCount){%>
    <a href="fenye1.jsp?pages=<%=intPageCount%>">最后一页</a><%}%>
    <!--<form>请输入您要查看的页码:
    <input name="intGetPage"type="text"class="text"size="10">
    <input name="submit_go"type="submit"class="file"value="go"></form>-->
    <%RS_result.close();%>
    </div>
    </BODY>
    </HTML>