JSP分页现实问题求助
想做个分页显示的小程序,但在用ResultSet的absolute方法定位到指定页面时,单步测试是报错如下:
Unsupported Method:ResultSet.absolute
这是什么原因呢?请前辈指教!
[解决办法]
这个定位函数也可以用,
[解决办法]
*****page.jsp********
<%@ page language= "java " contentType= "text/html;charset=GB2312 "%>
<%@ page import= "java.util.* "%>
<%@ page import= "ch14.* "%>
<%@ page import= "ch14.* "%>
<%@ page import= "book.* "%>
<html>
<head>
<title> 分页显示测试页面 </title>
<meta http-equiv= "Content-Type " content= "text/html;charset=GB2312 ">
</head>
<body>
<center>
<%
int pageNo = 1;
String strPage = request.getParameter( "jumpPage ");
if (strPage != null) {
pageNo = Integer.parseInt(strPage);
}
Pagination pageCtl = new bookpage();
pageCtl.setRowsPerPage(3);
pageCtl.setSQL( "SELECT * FROM books ");
Collection students = pageCtl.getPage(pageNo);
Iterator allStu = students.iterator();
%>
<h2> student表的查询结果分页显示: </h2>
<!--Student List-->
<table width= "740 " border= "1 " cellspacing= "0 " cellpadding= "6 ">
<tr>
<td width= "120 " align= "center " valign= "middle "> 编号 </td>
<td width= "145 " align= "center "> 姓名 </td>
<td width= "253 " align= "center "> 地址 </td>
<td width= "148 " align= "center "> 出生日期 </td>
</tr>
<%
while (allStu.hasNext()) {
book stu = (book)allStu.next();
%>
<tr>
<td height= "40 " align= "center " valign= "middle "> <%=stu.getId()%> </td>
<td align= "center " valign= "middle "> <%=stu.getName()%> </td>
<td valign= "middle "> <%=stu.getTitle()%> </td>
<td align= "center " valign= "middle "> <%=stu.getPrice()%> </td>
</tr>
<%
}
%>
</table>
<form action= "paginationTest.jsp " method= "post " name= "PageForm ">
每页 <%=pageCtl.getRowsPerPage()%> 行
共 <%=pageCtl.getRowsCount()%> 行
第 <%=pageNo%> 页
共 <%=pageCtl.getPagesCount()%> 页
<br>
<%
if(pageNo==1) {
out.print( " 首页 上一页 ");
}else {
%>
<a href= "javascript:gotoPage(1) "> 首页 </a>
<a href= "javascript:gotoPage( <%=pageNo-1%> ) "> 上一页 </a>
<%
}
%>
<%
if(pageNo==pageCtl.getPagesCount()) {
out.print( "下一页 尾页 ");
} else {
%>
<a href= "javascript:gotoPage( <%=pageNo+1%> ) "> 下一页 </a>
<a href= "javascript:gotoPage( <%=pageCtl.getPagesCount()%> ) "> 尾页 </a>
<%
}
%>
转到第
<select name= "jumpPage " onchange= "Jumping() ">
<%
for(int i=1; i <=pageCtl.getPagesCount(); i++) {
if (i == pageNo) {
%>
<option selected value= <%=i%> > <%=i%> </option>
<%
} else {
%>
<option value= <%=i%> > <%=i%> </option>
<%
}
}
%>
</select> 页
</form>
</center>
</body>
</html>
<Script Language= "JavaScript ">
function Jumping(){
document.PageForm.submit();
return ;
}
function gotoPage(pagenum){
document.PageForm.jumpPage.value = pagenum;
document.PageForm.submit();
return ;
}
</Script>