jsp实现分页显示时,如何传递中文参数到下一页?我的代码点击下一页时就没有数据了。
<%@ page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.sql.*" %>
<%@page language="java" import="java.util.*" %>
<%@page language="java" import="java.lang.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>按项目负责人查询</title>
</head>
<% //变量声明
request.setCharacterEncoding("GB2312");
Connection conn; //数据库连接对象
Statement stmt; //SQL语句对象
ResultSet rs; //结果集对象
String strCon; //数据库连接字符串
//SQL语句
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
//String name;
int i;
//设置一页显示的记录数
intPageSize = 1;
//取得待显示页码
strPage = request.getParameter("page");
if(strPage==null||strPage==""){//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
}
else{//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
//if(intPage<1) intPage = 1;
}
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url="jdbc:sqlserver://localhost:1433";
String user="sa";
String password="100862";
//装载JDBC驱动程序
Class.forName(driver).newInstance();
//设置数据库连接字符串
conn = java.sql.DriverManager.getConnection(url,user,password);
//创建一个可以滚动的只读的SQL语句对象
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql;
String fzr1 = request.getParameter("fzr"); //获取页面传来的号码
String fzr =new String(fzr1.getBytes("gb2312"),"gb2312");
//查询的语句
sql = "select * from ProjManagerPlatform.dbo.SprojInfo where sprojCharP = '"+fzr+"' " ;
//执行SQL语句并获取结果集
rs = stmt.executeQuery(sql);
//获取记录总数
rs.last();//??光标在最后一行
intRowCount = rs.getRow();//获得当前行号
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount) intPage = intPageCount;
%>
<body><center>
<h1 align="center">查询结果</h1>
<form method="POST">
第<%=intPage%>页 每页<%=intPageSize%>行 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href="searchFZR.jsp?page=<%=intPage+1%>&fzr=<%=fzr%>">下一页</a>
<%}%>
<%if(intPage>1){%>
<a href="searchFZR.jsp?page=<%=intPage-1%>&fzr=<%=fzr%>">上一页</a>
<%}%>
</form>
<table border="3" cellpadding="4" bordercolor="#a7a7a7" style="empty-cells: show; border-collapse: collapse;">
<tr bgcolor="#C0C0C0"><td>科研项目ID</td><td>科研项目名称</td><td>科研项目类型</td><td>科研项目类别</td><td>科研项目编号</td>
<td>项目来源</td><td>项目经费</td><td>科研项目描述</td><td>申请日期</td>
<td>项目人</td><td>参与人员</td><td>项目状态</td><td>结束日期</td>
<td>获奖情况</td><td>证书编号</td><td>科研论文名称</td><td>课题申请书</td><td>课题任务书</td>
<td>课题大纲</td><td>结题申请书</td><td>结题报告</td><td>验收报告</td>
<td>鉴定报告</td><td>报奖申请书</td><td>其他相关资料</td>
</tr>
<%if(intPageCount>0){
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1) * intPageSize + 1);
//显示数据
i = 0;
while(i<intPageSize && !rs.isAfterLast()){
String issABPath = rs.getString("issABPath");
String issTBPath = rs.getString("issTBPath");
String issOutlinePath = rs.getString("issOutlinePath");
String endABPath = rs.getString("endABPath");
String endReportPath = rs.getString("endReportPath");
String checkReportPath = rs.getString("checkReportPath");
String apprReportPath = rs.getString("apprReportPath");
String awdABPath = rs.getString("awdABPath");
String otherDataPath = rs.getString("otherDataPath");
%>
<tr><td><%=rs.getString("sprojId")%></td><td><%=rs.getString("sprojName")%></td><td><%=rs.getString("sprojType")%></td>
<td><%=rs.getString("sprojCate")%></td><td><%=rs.getString("sprojNum")%></td>
<td><%=rs.getString("projSource")%></td><td><%=rs.getString("projMoney")%></td>
<td><%=rs.getString("sprojDiscrb")%></td><td><%=rs.getString("applyDate")%></td>
<td><%=rs.getString("sprojCharP")%></td><td><%=rs.getString("sprojPartP")%></td>
<td><%=rs.getString("sprojCond")%></td><td><%=rs.getString("endDate")%></td>
<td><%=rs.getString("awardCond")%></td><td><%=rs.getString("certificateNum")%></td>
<td><%=rs.getString("projThesis")%></td>
<td><a href="downloadIssAB.jsp?issABPath=<%=issABPath%>"><%=rs.getString("issAB")%></a></td>
<td><a href="downloadIssTB.jsp?issTBPath=<%=issTBPath%>"><%=rs.getString("issTB")%></a></td>
<td><a href="downloadIssOutline.jsp?issOutlinePath=<%=issOutlinePath%>"><%=rs.getString("issOutline")%></a></td>
<td><a href="downloadEndAB.jsp?endABPath=<%=endABPath%>"><%=rs.getString("endAB")%></a></td>
<td><a href="downloadEndReport.jsp?endReportPath=<%=endReportPath%>"><%=rs.getString("endReport")%></a></td>
<td><a href="downloadCheckReport.jsp?checkReportPath=<%=checkReportPath%>"><%=rs.getString("checkReport")%></a></td>
<td><a href="downloadApprReport.jsp?apprReportPath=<%=apprReportPath%>"><%=rs.getString("apprReport")%></a></td>
<td><a href="downloadAwdAB.jsp?awdABPath=<%=awdABPath%>"><%=rs.getString("awdAB")%></a></td>
<td><a href="downloadOtherData.jsp?otherDataPath=<%=otherDataPath%>"><%=rs.getString("otherData")%></a></td>
</tr>
<%rs.next();
i++;
}
}%>
</table>
</center>
<%//关闭结果集
rs.close();
//关闭SQL语句对象
stmt.close();
//关闭数据库
conn.close();%>
</body>
</html>
其中fzr是我从html获得的中文,已经获得。但是点击下一页时,就不行了。。。求帮助啊
[解决办法]
<a href="searchFZR.jsp?page=<%=intPage+1%>&fzr=<%=fzr1%>">下一页</a>