我的要实现的目标:要显示的话要先输入“客户名称”,然后输出第一页,然后可以自由跳转到指定页。单分页显示我会做,单按“客户名称”查询我会做,搞到一起我就不会了!!!!
现在我把这两个弄到一起了,结果是输入“客户名称 ”的时候可以显示第一页,当跳转页时就什么都显示不出来了,跟刚进到页面时一样。
第一次进入地址栏: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=才对啊!
求救!!!!!!!!!
现在我把这两个弄到一起了,结果是输入“客户名称 ”的时候可以显示第一页,当跳转页时就什么都显示不出来了,跟刚进到页面时一样。
第一次进入地址栏: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=才对啊!
求救!!!!!!!!!
解决方案 »
- 一道百度算法比赛题
- java写入东西为什么是用输出流呢,在线等
- 有关JLabel的两个小问题,亟待解决
- 各位看看这是什么错误,帮忙解决看,谢谢!
- HashMap可以是关键字相同吗,如果要关键字相同的话用什么对象处理,请看程序,在线等
- List组件中哪个listener监听列表项下标变化的事件
- 在java中打开excel?
- ****157分,解决立马给分,UDP中文问题!!!!!
- 关于架构设计的一点小困惑,如何利用好interface和skeletal implementation
- 求java获取本地flash文件宽高数据
- 关于getGraphics().困了几天了,谢谢
- 是一个程序只有一个Graphics对象还是一个面板只有一个Graphics对象?
上google上找找估计问题是你没有把一些总页面数、当前页数、查询条件等等从第一个页面传到后面
输入第N页时http://localhost:8080/bbb/fenye1.jsp?page=1
不好给你源码.
思路如下:fenye1.jsp?h_customer=..&page=1
h_customer=...更加用户的名称从数据库搜索出结果放到ArrayList中,,
然后根据page截取记录集的内容.
我干脆把代码贴上咯:
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>