可能是游标的问题,请帮忙看看?
sayto 2003-09-12 12:08:08 我把出现的问题标在//******位置了
<%
ResultSet sqlRst;//记录集
int intPageSize;//每页显示记录数
int intPage;//当前页数
int intRowCount;//记录总数
int intPageCount;//总页数
int i;
String strPage;
String strSQL;
//设置一页显示的记录数
intPageSize = 20;
//取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){
intPage = 1;
}
else{
intPage = Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
//准备SQL语句
strSQL = "select * from gsxw";
//执行SQL语句并获取结果集
sqlRst = myBean.executeQuery(strSQL);
//获取记录总数
sqlRst.last();
intRowCount = sqlRst.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount) intPage = intPageCount;
%>
<%
if(intPageCount>0){
//将记录指针定位到待显示页的第一条记录上
sqlRst.absolute((intPage-1) * intPageSize +1);
i = 0;
while(i<intPageSize && !sqlRst.isAfterLast()){
%>
<%=sqlRst.getString("id")%>"><%=sqlRst.getString("id")%>"> //****问题出现在这里,这什么显示两次或两次以上id就会出错?我想可以是游标的问题,也可能是别的问题,也大家帮忙,谢谢!****
<%
sqlRst.next();
i++;
}
}
%>
<%if(intPage>1){%>
<a href="?page=<%=intPage-1%>">上一页</a>
<%}else{%>
上一页
<%}%>
<%if(intPage<intPageCount){%>
<a href="?page=<%=intPage+1%>">下一页</a>
<%}else{%>
下一页
<%}%>
页次<%=intPage%>/<%=intPageCount%> 共<%=intRowCount%>条
<%
//关闭结果集
sqlRst.close();
%>
//错误提示如下
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: No data found
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)
at org.apache.jsp.gsxw_0005flist$jsp._jspService(gsxw_0005flist$jsp.java:272)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)