各位,请帮我看看这个分页显示的页面,不能跳转,在线等待,谢谢
<%@ page contentType= "text/html;charset=GBK " %>
<%@ page language= "java " import= "java.sql.* "%>
<%@ page import= "java.lang.Math.* " %>
<jsp:useBean id= "conn " scope= "page " class= "test.ConnSQL "/>
<%!
ResultSet rs = null;
ResultSet rsTmp = null;
String sql = " ";
int PageSize = 30;
int Page = 3;
int totalPage = 1;
String str = " ";
%>
<%!
public String ShowOnePage(ResultSet rs, int Page, int PageSize) {
str = " ";
// 先将记录指针定位到相应的位置
try {
rs.absolute( (Page-1) * PageSize + 1);
}catch(SQLException e) {
}
for(int iPage=1; iPage <=PageSize; iPage++) {
str += RsToGbook(rs );
try {
if(!rs.next()) break;
}catch(Exception e) {}
}
return str;
}
// 显示单行记录子模块
public String RsToGbook( ResultSet rs ) {
String tt = " ";
try {
tt += " <TR> ";
tt += " <TD> " + rs.getString( "Trans_Name ") + " </TD> ";
tt += " <TD> " + rs.getString( "dst_termid ") + " </TD> ";
tt += " <TD> " + rs.getString( "src_termid ") + " </TD> ";
tt += " <TD> " + rs.getString( "msg_content ") + " </TD> ";
tt += " </TR> ";
}catch(SQLException e) {}
return tt;
}
%>
<% String begintime=request.getParameter( "beginDate ");
String endtime=request.getParameter( "endDate ");
sql = "select * from Teci_chat_mt where insert_time between ' "+begintime+ " ' "+ "and ' "+endtime+ " ' ";
try {
rs = conn.executeQuery( sql );
}catch(Exception e) {
out.println( "访问数据库出错! ");
}
%>
<html>
<head>
<title> 业务分页显示 </title>
</head>
<body bgcolor= "#FFFFFF ">
<h2 ALIGN= "CENTER "> 业务分页显示 </h2>
<hr>
<center>
<table border>
<TR bgcolor=lightblue>
<TH> 业务名称 </TH>
<TH> 用户号码 </TH>
<TH> 网关 </TH>
<TH> 内容 </TH>
</TR>
<%
rsTmp = conn.executeQuery( "select count(*) as mycount from Teci_chat_mt where insert_time between ' "+begintime+ " ' "+ "and ' "+endtime+ " ' ";
rsTmp.next();
int totalrecord = rsTmp.getInt( "mycount ");
if(totalrecord % PageSize ==0) totalPage = totalrecord / PageSize; // 如果是当前页码的整数倍
else totalPage = (int) Math.floor( totalrecord / PageSize ) + 1; // 如果最后还空余一页
if(totalPage == 0) totalPage = 1;
rsTmp.close();
try {
if(request.getParameter( "Page ")==null || request.getParameter( "Page ").equals( " "))
Page = 1;
else
Page = Integer.parseInt(request.getParameter( "Page "));
} catch(java.lang.NumberFormatException e) { // 捕获用户从浏览器地址拦直接输入Page=sdfsdfsdf所造成的异常
Page = 1;
}
if(Page < 1) Page = 1;
if(Page > totalPage) Page = totalPage;
out.println(ShowOnePage(rs, Page, PageSize));
%>
</table>
<form Action= "pagev3.jsp " Method= "GET ">
<%
if(Page != 1) {
out.println( " <A HREF=pagev3.jsp?Page=1> 第一页 </A> ");
out.println( " <A HREF=pagev3.jsp?Page= " + (Page-1) + "> 上一页 </A> ");
}
if(Page != totalPage) {
out.println( " <A HREF=pagev3.jsp?Page= " + (Page+1) + "> 下一页 </A> ");
out.println( " <A HREF=pagev3.jsp?Page= " + totalPage + "> 最后一页 </A> ");
}
rs.close();
%>
<p> 输入页数: <input TYPE= "TEXT " Name= "Page " SIZE= "3 "> 页数: <font COLOR= "Red "> <%=Page%> / <%=totalPage%> </font>
</p>
</form>
</center>
<hr>
</body>
</html>
这是我的总页面,在点击下一页的时候,显示的内容仍然是第一页显示的内容,我的bean是这样de:
package test;
import java.sql.*;
public class ConnSQL
{
Connection con=null;
Statement sql=null;
ResultSet rs=null;
public ConnSQL()
{
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String s)
{
try
{
con = DriverManager.getConnection( "jdbc:odbc:linkdatabase ", "sa ", "16898758 ");
sql = con.createStatement();
rs = sql.executeQuery(s);
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception.getMessage());
}
return rs;
}
public int executeUpdate(String s)
{
int i = 0;
try
{
con = DriverManager.getConnection( "jdbc:odbc:linkdatabase ", "sa ", "16898758 ");
sql = con.createStatement();
i = sql.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println(sqlexception.getMessage());
}
return i;
}
}请大家帮帮忙
[解决办法]
http://www.finereport.com