| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1391 人关注过本帖
标题:[求助]带参数的分页问题,问题已解决谢谢^_^
取消只看楼主 加入收藏
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
 问题点数:0 回复次数:7 
[求助]带参数的分页问题,问题已解决谢谢^_^

我用StringBuffer作了多条件查询后以前的分页就不管用了,请问这样应该怎么做分页啊??


我用的数据库是oracle。MYSQL那个方法用不了,虽然实现了多条件查询后以前的分页但是还是觉得我用的方法笨笨的,先凑合着用吧,呵呵谢谢大家的热心帮助。



<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.cdx.share.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%DBAccess db=new DBAccess("java:comp/env/jdbc/SLLY");%>
<%request.setCharacterEncoding("GB2312");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<LINK href="../css/cssDefault.css" type=text/css rel=stylesheet>
</head>

<body><table class=table1 cellspacing="1">

<%
String WATERSYSTEM=request.getParameter("WATERSYSTEM");
String D_TYPE=request.getParameter("D_TYPE");
String EA_TIME=request.getParameter("EA_TIME");
String RIVERNAME=request.getParameter("RIVERNAME");
String C_LOCUS=request.getParameter("C_LOCUS");
String D_DATE=request.getParameter("D_DATE");

StringBuffer sql=new StringBuffer("select * from T_DISSENSION t where 1=1 ");

if (WATERSYSTEM!=null&&!"".equals(WATERSYSTEM))
sql.append(" and t.WATERSYSTEM='"+WATERSYSTEM+"'" );
if (D_TYPE!=null&&!"".equals(D_TYPE))
sql.append(" and t.D_TYPE='"+D_TYPE+"'" );
if (EA_TIME!=null&&!"".equals(EA_TIME))
sql.append(" and t.EA_TIME='"+EA_TIME+"'" );
if (RIVERNAME!=null&&!"".equals(RIVERNAME))
sql.append(" and t.RIVERNAME='"+RIVERNAME+"'");
if (C_LOCUS!=null&&!"".equals(C_LOCUS))
sql.append(" and t.C_LOCUS='"+C_LOCUS+"'" );
if (D_DATE!=null&&!"".equals(D_DATE))
sql.append(" and t.D_DATE='"+D_DATE+"'" );

CDXResultSet rs=db.execQuery(sql.toString());
%>
<form name="frm1" method="post" action="DISSENSION.jsp">
<tr>
<td class=td3>选择河系</td>
<td class=td2>
<select name="WATERSYSTEM" class=select2>
<option value="" selected>-河系名称-</option>
<option value="黑龙江水系">黑龙江水系</option>
<option value="乌苏里江水系">乌苏里江水系</option>
<option value="绥芬河水系">绥芬河水系</option>
<option value="图们江水系">图们江水系</option>
<option value="额尔古纳河水系">额尔古纳河水系</option>
<option value="鸭绿江水系">鸭绿江水系</option>
<option value="其它(界湖)">其它(界湖)</option>
</select></td>
<td class=td3>选择类别</td>
<td class=td2>
<SELECT NAME="D_TYPE" class=select2>
<option value="" selected>-类型名称-</option>
<option value="水事纠纷">水事纠纷</option>
<option value="非水事纠纷">非水事纠纷</option>
</SELECT></td>
<td class=td3>审批时间</td>
<td class=td2><input class=text3 type="text" name="EA_TIME" value=""></td>
</tr>
<tr>
<td class=td3>河流名称</td>
<td class=td2><input class=text3 type="text" name="RIVERNAME" value=""></td>
<td class=td3>所在县市</td>
<td class=td2><input class=text3 type="text" name="C_LOCUS" value=""></td>
<td class=td3>时间</td>
<td class=td2><input class=text3 type="text" name="D_DATE" value=""></td>
</tr>
<tr class=trbottom>
<td colspan="6">
<input name=Submit type=image "img src="../images/button/btnQuery.gif" border="0">
<a href="DISSENSION_register.jsp"><img src="../images/button/btnAdd.gif" border="0"></a>
<input name=Back type=image "img src="../images/button/btnBack.gif" onClick="history.back(-1)" border="0"></td>
</tr>
</table>
</form>

<table class=table1 cellspacing="1">

<tr class=trhead>
<td width="16%">河流名称</td>
<td width="18%">所在县市</td>
<td width="18%">时间</td>
<td width="18%">类型</td>
<td width="15%">照会内容</td>
<td width="15%">备注</td>
</tr>

<%
while(rs.next()){
%>
<tr class=tr1>
<td><%=rs.getString("RIVERNAME")%></td>
<td><%=rs.getString("C_LOCUS")%></td>
<td><%=rs.getString("D_DATE")%></td>
<td><%=rs.getString("D_TYPE")%></td>
<td><%=rs.getString("NOTE")%></td>
<td><%=rs.getString("REMARK")%></td>
</tr>
<%}}%>

<tr class=trbottom>
<td colspan="6" >
</td>
</tr>

</table>
</body>
</html>

[此贴子已经被作者于2006-9-25 9:43:37编辑过]

搜索更多相关主题的帖子: import 数据库 参数 java 
2006-09-21 09:42
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 
啊呀。。你找到解决办法了的话麻烦你也告诉我
2006-09-21 10:30
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 

以前用这个分页的,但是用了StringBuffer后就不知道该怎么用了


<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.cdx.share.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%DBAccess db=new DBAccess("java:comp/env/jdbc/SLLY");%>
<%request.setCharacterEncoding("GB2312");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>国际河流名称总表</title>
<LINK href="css/cssDefault.css" type=text/css rel=stylesheet>
</head>

<body><div><tr>&nbsp;</tr>
<table class=table1 cellspacing="1">

<tr height="20">
<td background="images/table/bg_line4.jpg" class=td4 colspan=8>
<IMG src="images/table/ball.gif">国&nbsp;际&nbsp;河&nbsp;流&nbsp;名&nbsp;称&nbsp;总&nbsp;表<IMG src="images/table/ball.gif">
</td></tr>

<form method="post" action="T_R_N_L.jsp">
<tr>
<td width="20%" class=td3>选择河系</td>
<td colspan="2" width="20%" class=td2>
<select name="WATERSYSTEM" class=select2>
<option value="" selected>-河系名称-</option>
<option value="黑龙江水系">黑龙江水系</option>
<option value="乌苏里江水系">乌苏里江水系</option>
<option value="绥芬河水系">绥芬河水系</option>
<option value="图们江水系">图们江水系</option>
<option value="额尔古纳河水系">额尔古纳河水系</option>
<option value="鸭绿江水系">鸭绿江水系</option>
<option value="其它(界湖)">其它(界湖)</option>
</select></td>
<td width="20%" class=td3>选择类别</td>
<td colspan="2" width="20%" class=td2>
<SELECT NAME="WATERSYSTEMTYPE" class=select2>
<option value="" selected>-河系类别-</option>
<option value="干流">干流</option>
<option value="一级支流">一级支流</option>
<option value="二级支流">二级支流</option>
<option value="其它">其它</option>
</SELECT></td>
<td colspan="2" width="20%" class=td3>
<input type="Submit" value="检索" name="js" class=button1></td>
</tr>
</form>
<form name="fm" method="post" action="">

<tr class=trhead>
<td>河流名称</td>
<td>河流编码</td>
<td>所属河系</td>
<td>上级河流名称</td>
<td>上级河流编码</td>
<td>所属河系类型</td>
<td>两岸国别</td>
<td>备注</td>
</tr>
<%
//添加翻页
int i=0;
MultiPage mp = MultiPage.getInstance(request);
ArrayList al = new ArrayList();//数组
ArrayList altemp = new ArrayList();

String WATERSYSTEM = request.getParameter("WATERSYSTEM");
String WATERSYSTEMTYPE = request.getParameter("WATERSYSTEMTYPE");

String sql="";
if(!WATERSYSTEM.equals("")&&!WATERSYSTEMTYPE.equals(""))
{
al=db.executeQuery("select * from T_RIVERNAME where WATERSYSTEM='"+WATERSYSTEM+"' and WATERSYSTEMTYPE='"+WATERSYSTEMTYPE+"'");
}
else if(WATERSYSTEM.equals("")&&WATERSYSTEMTYPE.equals(""))
{
al=db.executeQuery("select * from T_RIVERNAME");
}
else if(!WATERSYSTEM.equals("")&&WATERSYSTEMTYPE.equals(""))
{
al=db.executeQuery("select * from T_RIVERNAME where WATERSYSTEM='"+WATERSYSTEM+"'");
}
else if(WATERSYSTEM.equals("")&&!WATERSYSTEMTYPE.equals(""))
{
al=db.executeQuery("select * from T_RIVERNAME where WATERSYSTEMTYPE='"+WATERSYSTEMTYPE+"'");
}


mp.setPageData("cny",al) ;
al = (ArrayList)mp.getPageData("cny") ;
mp.setTotalSize(al.size());

for (i=mp.getStartRowNo();i<mp.getEndRowNo();i++){

altemp = (ArrayList)al.get(i) ;
%>
<tr class='<%=(i%2==0)?"tr1":"tr2"%>'><!--三目运算符-->
<td><%=altemp.get(1)%></td>
<td><%=altemp.get(0)%></td>
<td><%=altemp.get(2)%></td>
<td><%=altemp.get(3)%></td>
<td><%=altemp.get(4)%></td>
<td><%=altemp.get(5)%></td>
<td><%=altemp.get(6)%></td>
<td><%=altemp.get(7)%></td>
</tr>
<%}%>

<tr class=trbottom>
<td colspan="8" >
<%=mp.getNavigation("T_R_N_L.jsp")%>
</td>
</tr>
<input type="hidden" name="WATERSYSTEM" value="<%=altemp.get(2)%>">
<input type="hidden" name="WATERSYSTEMTYPE" value="<%=altemp.get(5)%>">
</form>
</table>
</body>
</html>

2006-09-22 09:26
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 
在线等,谢谢高手指点迷津啊
2006-09-22 09:41
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 
哇,好高兴,终于有人教我做了,我这就去试试,嘿嘿,谢谢!!!
2006-09-22 15:03
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 

哎呀。我试过了,用sub替换to就直接报错。。。。

现在不报错了,但是分页分了用不了fm.iPageSize说这个缺少对象


<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.cdx.share.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%DBAccess db=new DBAccess("java:comp/env/jdbc/SLLY");%>
<%request.setCharacterEncoding("GB2312");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>水事纠纷</title>
<LINK href="../css/cssDefault.css" type=text/css rel=stylesheet>
</head>

<body><div><tr>&nbsp;</tr>
<table class=table1 cellspacing="1">

<tr height="20">
<td background="../images/table/bg_line4.jpg" class=td4 colspan=6>
<img src="../images/table/ball.gif">水&nbsp;事&nbsp;纠&nbsp;纷<img src="../images/table/ball.gif"></td></tr>

<form name="fm" method="post" action="DISSENSION.jsp">

<tr>
<td class=td3>选择河系</td>
<td class=td2>
<select name="WATERSYSTEM" class=select2>
<option value="" selected>-河系名称-</option>
<option value="黑龙江水系">黑龙江水系</option>
<option value="乌苏里江水系">乌苏里江水系</option>
<option value="绥芬河水系">绥芬河水系</option>
<option value="图们江水系">图们江水系</option>
<option value="额尔古纳河水系">额尔古纳河水系</option>
<option value="鸭绿江水系">鸭绿江水系</option>
<option value="其它(界湖)">其它(界湖)</option>
</select></td>
<td class=td3>选择类别</td>
<td class=td2>
<SELECT NAME="D_TYPE" class=select2>
<option value="" selected>-类型名称-</option>
<option value="水事纠纷">水事纠纷</option>
<option value="非水事纠纷">非水事纠纷</option>
</SELECT></td>
<td class=td3>审批时间</td>
<td class=td2><input class=text3 type="text" name="EA_TIME" value=""></td>
</tr>
<tr>
<td class=td3>河流名称</td>
<td class=td2><input class=text3 type="text" name="RIVERNAME" value=""></td>
<td class=td3>所在县市</td>
<td class=td2><input class=text3 type="text" name="C_LOCUS" value=""></td>
<td class=td3>时间</td>
<td class=td2><input class=text3 type="text" name="D_DATE" value=""></td>
</tr>
<tr class=trbottom>
<td colspan="6">
<input name=Submit type=image "img src="../images/button/btnQuery.gif" border="0">
<a href="DISSENSION_register.jsp"><img src="../images/button/btnAdd.gif" border="0"></a>
<input name=Back type=image "img src="../images/button/btnBack.gif" onClick="history.back(-1)" border="0"></td>
</tr>
</table>
</form>

<table class=table1 cellspacing="1">
<tr height="20">
<td background="images/table/bg_line4.jpg" class=td4 colspan=6>水事纠纷信息表</td>
</tr>

<tr class=trhead>
<td width="16%">河流名称</td>
<td width="18%">所在县市</td>
<td width="18%">时间</td>
<td width="18%">类型</td>
<td width="15%">照会内容</td>
<td width="15%">备注</td>
</tr>
<%
//添加翻页
int i=0;
MultiPage mp = MultiPage.getInstance(request);
ArrayList al = new ArrayList();//数组
ArrayList altemp = new ArrayList();

String WATERSYSTEM=request.getParameter("WATERSYSTEM");
String D_TYPE=request.getParameter("D_TYPE");
String EA_TIME=request.getParameter("EA_TIME");
String RIVERNAME=request.getParameter("RIVERNAME");
String C_LOCUS=request.getParameter("C_LOCUS");
String D_DATE=request.getParameter("D_DATE");

StringBuffer sql=new StringBuffer("select * from T_DISSENSION t where 1=1 ");

if (WATERSYSTEM!=null&&!"".equals(WATERSYSTEM))
sql.append(" and t.WATERSYSTEM='"+WATERSYSTEM+"'");
if (D_TYPE!=null&&!"".equals(D_TYPE))
sql.append(" and t.D_TYPE='"+D_TYPE+"'");
if (EA_TIME!=null&&!"".equals(EA_TIME))
sql.append(" and t.EA_TIME='"+EA_TIME+"'");
if (RIVERNAME!=null&&!"".equals(RIVERNAME))
sql.append(" and t.RIVERNAME='"+RIVERNAME+"'");
if (C_LOCUS!=null&&!"".equals(C_LOCUS))
sql.append(" and t.C_LOCUS='"+C_LOCUS+"'");
if (D_DATE!=null&&!"".equals(D_DATE))
sql.append(" and t.D_DATE='"+D_DATE+"'" );

al=db.executeQuery(sql.toString());

mp.setPageData("cny",al);
al = (ArrayList)mp.getPageData("cny");
mp.setTotalSize(al.size());

for (i=mp.getStartRowNo();i<mp.getEndRowNo();i++){

altemp = (ArrayList)al.get(i);
%>
<tr class='<%=(i%2==0)?"tr1":"tr2"%>'><!--三目运算符-->
<td><a href="DISSENSION2.jsp?ID=<%=altemp.get(13)%>"><%=altemp.get(1)%></a></td>
<td><%=altemp.get(3)%></td>
<td><%=altemp.get(8)%></td>
<td><%=altemp.get(4)%></td>
<td><%=altemp.get(10)%></td>
<td><%=altemp.get(12)%></td>
</tr>
<%}%>
<tr class=trbottom>
<td colspan="6"><%=mp.getNavigation("DISSENSION.jsp")%></td>
</tr>

</table>
</body>
</html>

[此贴子已经被作者于2006-9-22 15:37:10编辑过]

2006-09-22 15:34
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 

这个是引用的文件

// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date: 2006-8-10 11:35:20
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: MultiPage.java

package com.cdx.share;

import java.util.Enumeration;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

// Referenced classes of package com.cdx.share:
// ConfigManager

public class MultiPage
{

public MultiPage()
{
iTotalSize = 0;
iPageSize = 0;
iPage = 1;
iRowStart = 0;
iRowEnd = 0;
iPageCount = 2;
htUserArea = new Hashtable();
}

public static MultiPage getInstance(HttpServletRequest request)
throws Exception
{
MultiPage cMultiPage;
Object objMultiPage = request.getSession().getAttribute("cMultiPage");
if(objMultiPage == null)
{
cMultiPage = new MultiPage();
request.getSession().setAttribute("cMultiPage", cMultiPage);
} else
{
cMultiPage = (MultiPage)objMultiPage;
}
if(cMultiPage.iPageSize == 0)
{
String SiPageSize = ConfigManager.getValue("PerPageRecordCount");
if(SiPageSize.equals("0"))
SiPageSize = "20";
cMultiPage.iPageSize = Integer.parseInt(SiPageSize);
}
for(Enumeration eKey = cMultiPage.htUserArea.keys(); eKey.hasMoreElements();)
{
String sKey = eKey.nextElement().toString();
Object obj = request.getAttribute(sKey);
if(obj == null)
{
request.setAttribute(sKey, cMultiPage.htUserArea.get(sKey));
} else
{
request.setAttribute(sKey, obj);
cMultiPage.iPage = 1;
}
}

String SiPage = request.getParameter("iPagePara");
if(SiPage == null || SiPage.equals(""))
SiPage = "1";
cMultiPage.iPage = Integer.parseInt(SiPage);
String SiPageSize = request.getParameter("iPageSizePara");
if(SiPageSize != null)
{
cMultiPage.iPageSize = Integer.parseInt(SiPageSize);
int iPages = cMultiPage.iTotalSize / cMultiPage.iPageSize;
if(cMultiPage.iTotalSize % cMultiPage.iPageSize > 0)
iPages++;
if(cMultiPage.iPage > iPages)
cMultiPage.iPage = iPages;
if(cMultiPage.iPage == 0)
cMultiPage.iPage = 1;
}
return cMultiPage;
Exception e;
e;
e.printStackTrace(System.out);
throw e;
}

public String getNavigation(String sURL)
throws Exception
{
return getNavigation(sURL, "");
}

public String getNavigation(String sURL, String sPara)
throws Exception
{
String sReturn;
int iPages = iTotalSize / iPageSize;
if(iTotalSize % iPageSize > 0)
iPages++;
int iPageCountS = iPage - iPageCount;
int iPageCountE = iPage + iPageCount;
if(iPageCountS < iPageCount)
iPageCountE = 2 * iPageCount + 1;
if(iPageCountE > iPages)
iPageCountS = iPages - 2 * iPageCount;
if(iPageCountS < 1)
iPageCountS = 1;
if(iPageCountE > iPages)
iPageCountE = iPages;
sReturn = "<script type=text/javascript>\r\n";
sReturn = sReturn + "function PageShowPage(iPagePara)\r\n";
sReturn = sReturn + "{\r\n";
sReturn = sReturn + " var obj=0; var iPageSizeParaValue=20;\r\n";
sReturn = sReturn + " try{obj=iPageSizePara;}catch(pe){ for(var m=0;m<document.forms.length;m++){ try{obj=document.forms[m]['iPageSizePara'];if(typeof obj == 'object') break;}catch(pe2){}; } };\r\n";
sReturn = sReturn + " if(obj!=0) iPageSizeParaValue=obj.value;\r\n";
sReturn = sReturn + " if(iPageSizeParaValue.length==0)\r\n";
sReturn = sReturn + " {\r\n";
sReturn = sReturn + " alert('\u8BF7\u8F93\u5165\u6BCF\u9875\u663E\u793A\u6570!'); obj.value='" + iPageSize + "';if(obj!=0) obj.focus();\r\n";
sReturn = sReturn + " }\r\n";
sReturn = sReturn + " else \r\n";
sReturn = sReturn + " {";
sReturn = sReturn + " fm.action= '" + sURL + "' ; ";
sReturn = sReturn + " fm.iPagePara.value= iPagePara ;";
sReturn = sReturn + " fm.iPageSizePara.value= iPageSizeParaValue ;";
sReturn = sReturn + " fm.submit() ;";
sReturn = sReturn + " }";
sReturn = sReturn + "}\r\n";
sReturn = sReturn + "function PageCheckNumber(obj) {var varNumbers='0123456789'; for(var i=0;i<obj.value.length;i++){if(obj.value==0 || varNumbers.indexOf(obj.value.charAt(i))==-1){if(obj.name=='iPageSizePara') obj.value='" + iPageSize + "'; else obj.value='" + iPage + "'; alert('\u8BF7\u8F93\u5165\u6B63\u6574\u6570!'); obj.focus(); return false;} } return true;}\r\n";
sReturn = sReturn + "function goPageSize()\r\n";
sReturn = sReturn + "{\r\n";
sReturn = sReturn + " var obj=0; var iPageParaValue=1;\r\n";
sReturn = sReturn + " try{obj=iPagePara;}catch(pe){for(var m=0;m<document.forms.length;m++){try{obj=document.forms[m]['iPagePara'];if(typeof obj == 'object') break;}catch(pe2){};}};\r\n";
sReturn = sReturn + " if(obj!=0) iPageParaValue=obj.value;\r\n";
sReturn = sReturn + " if(iPageParaValue=='') iPageParaValue='" + iPage + "'\r\n";
sReturn = sReturn + " if(iPageParaValue>" + iPages + " || iPageParaValue.length==0)\r\n";
sReturn = sReturn + " {\r\n";
sReturn = sReturn + " alert('\u8BF7\u8F93\u5165\u6570\u5B57\uFF0C\u8303\u56F4\u4E3A: 1 \u5230 " + iPages + " !'); if(obj!=0) obj.focus();\r\n";
sReturn = sReturn + " }\r\n";
sReturn = sReturn + " else\r\n";
sReturn = sReturn + " PageShowPage(iPageParaValue);\r\n";
sReturn = sReturn + "}\r\n";
sReturn = sReturn + "function PageKeyEnterPage(obj) {if(event.keyCode==13) {if(PageCheckNumber(obj) && obj.value!=\"\") goPageSize(); event.cancelBubble=true; event.returnValue=false;} }\r\n";
sReturn = sReturn + "function PageKeyEnterSize(obj) {if(event.keyCode==13) {if(PageCheckNumber(obj) && obj.value!=\"\") goPageSize(); event.cancelBubble=true; event.returnValue=false;} }\r\n";
sReturn = sReturn + "function PageGoPage_onClick() {var iPageParaValue=0;var obj=0; try{iPageParaValue=iPagePara.value;obj=iPagePara;}catch(pe){for(var m=0;m<document.forms.length;m++){try{iPageParaValue=document.forms[m][\"iPagePara\"].value;obj==document.forms[m][\"iPagePara\"];if(typeof obj == 'object') break;}catch(pe2){};}}; if(iPageParaValue!=0) goPageSize(); else if(obj!=0) obj.focus();}\r\n";
sReturn = sReturn + "</script>\r\n";
sReturn = sReturn + "|\u884C\u6570:";
sReturn = sReturn + iTotalSize + "|\u9875\u6570:";
sReturn = sReturn + iPage + "/" + iPages;
sReturn = sReturn + "|&nbsp;";
if(iPage > 1)
{
sReturn = sReturn + "<a href='javascript: PageShowPage(" + 1 + ");'><font face='webdings'>9</font></a>";
sReturn = sReturn + "<a href='javascript: PageShowPage(" + (iPage - 1) + ");'><font face='webdings'>7</font></a>";
} else
{
sReturn = sReturn + "<font color=gray face='webdings'>9</font>";
sReturn = sReturn + "<font color=gray face='webdings'>7</font>";
}
sReturn = sReturn + "&nbsp;";
for(int i = iPageCountS; i <= iPageCountE; i++)
{
if(iPage != i)
sReturn = sReturn + "<a href='javascript: PageShowPage(" + i + ");'>";
else
sReturn = sReturn + "<font color=red>";
sReturn = sReturn + i;
if(iPage != i)
sReturn = sReturn + "</a>\r\n";
else
sReturn = sReturn + "</font>\r\n";
if(i < iPageCountE)
sReturn = sReturn + "&nbsp;";
}

if(iPage < iPages)
{
sReturn = sReturn + "<a href='javascript: PageShowPage(" + (iPage + 1) + ");'><font face='webdings'>8</font></a>";
sReturn = sReturn + "<a href='javascript: PageShowPage(" + iPages + ");'><font face='webdings'>:</font></a>";
} else
{
sReturn = sReturn + "<font color=gray face='webdings'>8</font>";
sReturn = sReturn + "<font color=gray face='webdings'>:</font>";
}
sReturn = sReturn + "&nbsp;|";
sReturn = sReturn + "<a id='PageGoPage' href='javascript: PageGoPage_onClick();'>\u8F6C\u5230</a>";
sReturn = sReturn + "<input name='iPagePara' type='text' style='BACKGROUND: transparence; BORDER-BOTTOM: #BBBBBB 1px solid; BORDER-LEFT: #BBBBBB 0px solid; BORDER-RIGHT: #BBBBBB 0px solid; BORDER-TOP: #BBBBBB 0px solid; FONT-SIZE: 12px; text-align:center' size=2 onkeydown='javascript: PageKeyEnterPage(this);' onblur='javascript: PageCheckNumber(this);event.returnValue=false;'>|";
sReturn = sReturn + "<a href='javascript: goPageSize();'>\u6BCF\u9875</a>";
sReturn = sReturn + "<input name='iPageSizePara' type='text' style='BACKGROUND: transparence; BORDER-BOTTOM: #BBBBBB 1px solid; BORDER-LEFT: #BBBBBB 0px solid; BORDER-RIGHT: #BBBBBB 0px solid; BORDER-TOP: #BBBBBB 0px solid; FONT-SIZE: 12px; text-align:center' size=2 onkeydown='javascript: PageKeyEnterSize(this);' onblur='javascript: PageCheckNumber(this);event.returnValue=false;' value='" + iPageSize + "'>|\r\n";
return sReturn;
Exception e;
e;
throw e;
}

public void setPageData(String key, Object obj)
{
htUserArea.put(key, obj);
}

public Object getPageData(String key)
{
return htUserArea.get(key);
}

public void setTotalSize(int iTotalSize)
{
this.iTotalSize = iTotalSize;
iRowStart = (iPage - 1) * iPageSize;
iRowEnd = iPage * iPageSize;
if(iRowEnd > this.iTotalSize)
iRowEnd = this.iTotalSize;
}

public int getPageSize()
{
return iPageSize;
}

public int getStartRowNo()
{
return iRowStart;
}

public int getEndRowNo()
{
return iRowEnd;
}

public int getTotalSize()
{
return iTotalSize;
}

public int getTotalPages()
{
if(iPageSize == 0)
iPageSize = 1;
int iPages = iTotalSize / iPageSize;
if(iTotalSize % iPageSize > 0)
iPages++;
return iPages;
}

private int iTotalSize;
private int iPageSize;
private int iPage;
private int iRowStart;
private int iRowEnd;
private int iPageCount;
private Hashtable htUserArea;
}

2006-09-22 15:34
暖安丫头
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-9-20
收藏
得分:0 

谢谢大家的热心帮助,我的问题在和同事的讨论中圆满解决,放出解决方案感谢帮助过我的各位高手们

实现功能:多条件组合查询并分页

最后结果如下:
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.cdx.share.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%DBAccess db=new DBAccess("java:comp/env/jdbc/SLLY");%>
<%request.setCharacterEncoding("GB2312");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>水事纠纷</title>
<LINK href="../css/cssDefault.css" type=text/css rel=stylesheet>
</head>

<body><div><tr>&nbsp;</tr>
<table class=table1 cellspacing="1">

<tr height="20">
<td background="../images/table/bg_line4.jpg" class=td4 colspan=6>
<img src="../images/table/ball.gif">水&nbsp;事&nbsp;纠&nbsp;纷<img src="../images/table/ball.gif"></td></tr>

<form name="fm" method="post" action="DISSENSION.jsp">
<%
String WATERSYSTEM=request.getParameter("WATERSYSTEM");
String D_TYPE=request.getParameter("D_TYPE");
String EA_TIME=request.getParameter("EA_TIME");
String RIVERNAME=request.getParameter("RIVERNAME");
String C_LOCUS=request.getParameter("C_LOCUS");
String D_DATE=request.getParameter("D_DATE");

if ((WATERSYSTEM==null)||(WATERSYSTEM==""))
{
WATERSYSTEM="";
}if ((D_TYPE==null)||(D_TYPE==""))
{
D_TYPE="";
}if ((EA_TIME==null)||(EA_TIME==""))
{
EA_TIME="";
}if ((RIVERNAME==null)||(RIVERNAME==""))
{
RIVERNAME="";
}if ((C_LOCUS==null)||(C_LOCUS==""))
{
C_LOCUS="";
}if ((D_DATE==null)||(D_DATE==""))
{
D_DATE="";
}
%>
<tr>
<td class=td3>选择河系</td>
<td class=td2>
<select name="WATERSYSTEM" class=select2>
<option value="<%=WATERSYSTEM%>" selected><%=WATERSYSTEM%></option>
<option value="黑龙江水系">黑龙江水系</option>
<option value="乌苏里江水系">乌苏里江水系</option>
<option value="绥芬河水系">绥芬河水系</option>
<option value="图们江水系">图们江水系</option>
<option value="额尔古纳河水系">额尔古纳河水系</option>
<option value="鸭绿江水系">鸭绿江水系</option>
<option value="其它(界湖)">其它(界湖)</option>
</select></td>
<td class=td3>选择类别</td>
<td class=td2>
<SELECT NAME="D_TYPE" class=select2>
<option value="<%=D_TYPE%>" selected><%=D_TYPE%></option>
<option value="水事纠纷">水事纠纷</option>
<option value="非水事纠纷">非水事纠纷</option>
</SELECT></td>
<td class=td3>审批时间</td>
<td class=td2><input class=text3 type="text" name="EA_TIME" value="<%=EA_TIME%>"></td>
</tr>
<tr>
<td class=td3>河流名称</td>
<td class=td2><input class=text3 type="text" name="RIVERNAME" value="<%=RIVERNAME%>"></td>
<td class=td3>所在县市</td>
<td class=td2><input class=text3 type="text" name="C_LOCUS" value="<%=C_LOCUS%>"></td>
<td class=td3>时间</td>
<td class=td2><input class=text3 type="text" name="D_DATE" value="<%=D_DATE%>"></td>
</tr>
<tr class=trbottom>
<td colspan="6">
<input name=Submit type=image "img src="../images/button/btnQuery.gif" border="0">
<a href="DISSENSION_register.jsp"><img src="../images/button/btnAdd.gif" border="0"></a>
<input name=Back type=image "img src="../images/button/btnBack.gif" onClick="history.back(-1)" border="0"></td>
</tr>
</table>


<table class=table1 cellspacing="1">
<tr height="20">
<td background="images/table/bg_line4.jpg" class=td4 colspan=6>水事纠纷信息表</td>
</tr>

<tr class=trhead>
<td width="16%">河流名称</td>
<td width="18%">所在县市</td>
<td width="18%">时间</td>
<td width="18%">类型</td>
<td width="15%">照会内容</td>
<td width="15%">备注</td>
</tr>
<%
//添加翻页
int i=0;
MultiPage mp = MultiPage.getInstance(request);
ArrayList al = new ArrayList();//数组
ArrayList altemp = new ArrayList();

StringBuffer sql=new StringBuffer("select * from T_DISSENSION t where 1=1 ");

if (WATERSYSTEM!=null&&!"".equals(WATERSYSTEM))
sql.append(" and t.WATERSYSTEM='"+WATERSYSTEM+"'");
if (D_TYPE!=null&&!"".equals(D_TYPE))
sql.append(" and t.D_TYPE='"+D_TYPE+"'");
if (EA_TIME!=null&&!"".equals(EA_TIME))
sql.append(" and t.EA_TIME='"+EA_TIME+"'");
if (RIVERNAME!=null&&!"".equals(RIVERNAME))
sql.append(" and t.RIVERNAME='"+RIVERNAME+"'");
if (C_LOCUS!=null&&!"".equals(C_LOCUS))
sql.append(" and t.C_LOCUS='"+C_LOCUS+"'");
if (D_DATE!=null&&!"".equals(D_DATE))
sql.append(" and t.D_DATE='"+D_DATE+"'" );

al=db.executeQuery(sql.toString());

mp.setPageData("cny",al);
al = (ArrayList)mp.getPageData("cny");
mp.setTotalSize(al.size());

for (i=mp.getStartRowNo();i<mp.getEndRowNo();i++){

altemp = (ArrayList)al.get(i);
%>
<tr class='<%=(i%2==0)?"tr1":"tr2"%>'><!--三目运算符-->
<td><a href="DISSENSION2.jsp?ID=<%=altemp.get(13)%>"><%=altemp.get(1)%></a></td>
<td><%=altemp.get(3)%></td>
<td><%=altemp.get(8)%></td>
<td><%=altemp.get(4)%></td>
<td><%=altemp.get(10)%></td>
<td><%=altemp.get(12)%></td>
</tr>
<%}%>
<tr class=trbottom>
<td colspan="6"><%=mp.getNavigation("DISSENSION.jsp")%></td>
</tr>

</table></form>
</body>
</html>

2006-09-22 17:22
快速回复:[求助]带参数的分页问题,问题已解决谢谢^_^
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040177 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved