当前位置: 代码迷 >> Java Web开发 >> JSP分页现实有关问题
  详细解决方案

JSP分页现实有关问题

热度:61   发布时间:2016-04-17 15:55:36.0
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()%> 行&nbsp;
共 <%=pageCtl.getRowsCount()%> 行&nbsp;
第 <%=pageNo%> 页&nbsp;
共 <%=pageCtl.getPagesCount()%> 页
<br>
<%
if(pageNo==1) {
out.print( " 首页 上一页 ");
}else {
%>
<a href= "javascript:gotoPage(1) "> 首页 </a> &nbsp;
<a href= "javascript:gotoPage( <%=pageNo-1%> ) "> 上一页 </a> &nbsp;
<%
}
%>
<%
if(pageNo==pageCtl.getPagesCount()) {
out.print( "下一页 尾页 ");
} else {
%>
  相关解决方案