关于分页显示的问题,高分求助
在JSP查寻中,上下页的连接只对默认参数的查寻结果正确,如果我输入其他参数,程序能够正确判断中新参数所检索出的总数据的总页数并正确显示了第一页的内容,但是点击“下一页”时就会自动连接到默认参数所检索出数据的下一页。如何解决,恳请大家的帮助。
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*" %>
<%@ page import="com.hand.hayao.reports.*" %>
<%@ page import="com.hand.hayao.reports.vo.*" %>
<%@ page import="com.hand.common.db.*"%>
<%@ page import="com.hand.hayao.*"%>
<%@ include file="validation.jsp" %>
<%
String dateStr ="";
String currentDate ="";
Vector itemSalesList = new Vector();
Connection conn = null;
boolean isValideDate = false;
try{
conn = ConnectionManager.getConnection(AppManager.JDBC_NAME);
if (!sessionManager.hasPrivilege(conn, new Long(1))) {
sessionManager.showMsg(response, sessionManager.MSG_WARNING, "您没有权限查看此项内容");
return;
}
java.sql.Date current = DbUtils.getOracleCurrentDT(conn);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
currentDate = String.valueOf(Integer.parseInt(sdf.format(current))-1);
dateStr = request.getParameter("datestr")==null?currentDate: request.getParameter("datestr");
isValideDate = DbUtils.isValideDateString(conn, dateStr);
itemSalesList = InterfaceCuxItemSalesDetai.queryByDateAndOrder(conn, dateStr);
} catch(Exception e) {
e.printStackTrace();
throw e;
} finally {
conn.close();
}
%>
<%
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
java.lang.String strPage;//从地址栏中取到的page值
java.lang.String tt;
//设置一页显示的记录数
intPageSize = 21;
//取得待显示页码
tt=request.getParameter("aa");
strPage = request.getParameter("page");
if(strPage==null || tt=="bb"){//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
}
else{//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
intRowCount = itemSalesList.size();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if (intPageCount >1 && tt=="bb"){
if(intPage>intPageCount) intPage = intPageCount;}
int j=intPageSize*(intPage-1);
int end=0;
if((intPageSize*intPage-1)>=intRowCount)
{
end=intRowCount;
}
else
{
end=intPageSize*intPage;
}
if(intPageCount==0) intPageCount=1;%>
<html>
<head><title>查寻</title></head>
<script language="JavaScript">
</script>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<%@ include file="header.jsp"%>
<table width="980" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="get" action="../jsp/arrangebygoods.jsp">
<tr>
<td background="../images/navbar.gif"><font size="2">请输入查询日期:</font>
<INPUT TYPE="text" NAME="datestr" SIZE="10" VALUE= <%=dateStr=="sysdate"?"today":dateStr%>>
<INPUT name="submit" TYPE="submit" VALUE="确定">
(yyyymm) </td>
</tr>
</form>
</table>
<HR width="980">
销量排名(按物品):<BR>
<TABLE width="980" border="0" align="center">
<TR bgcolor="#4C83BB">
<TD width="42" nowrap align="center"><font color="#FFFFFF">排名</font></TD>
<TD width="435" nowrap align="center"><font color="#FFFFFF">物品名称</font></TD>
<TD width="187" nowrap align="center"><font color="#FFFFFF">销售数量</font></TD>
<TD width="298" nowrap align="center"><font color="#FFFFFF">销售金额</font></TD>
</TR>
<%
int i;
InterfaceCuxItemSalesDetaiVO vo = null;
for(i=j;i<end;i++) {
vo = (InterfaceCuxItemSalesDetaiVO) itemSalesList.get(i);
%>
<TR bgcolor="#99CC99">
<TD width="42" align="center" nowrap><font size="2"><%=vo.getOrderSalesForDay()%></font></TD>
<TD width="435" align="left" nowrap ><font size="2"><%=vo.getItemDescription()%></font></TD>
<TD width="187" align="right" nowrap><font size="2"><%=vo.getSalesQuantities()%></font></TD>
<TD width="298" align="right" nowrap><font size="2"><%=vo.getSalesAmmount()%></font></TD>
</TR>
<%
}
%>
</TABLE>
<%//根据情况调整一下连接%>
<div align="center">第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage>1){%>
<a href="../jsp/arrangebygoods.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if(intPage<intPageCount){%>
<a href="../jsp/arrangebygoods.jsp?page=<%=intPage+1%>">下一页</a>
<%}%>
</div>
<HR align="center" width="980">
</body>
</html>