JSP数据分页报After end of result set错误
Java code<% ResultSet rs = null; Connection con=null; java.sql.Statement state =null; request.setCharacterEncoding("utf-8"); String list = request.getParameter("list"); String value = request.getParameter("value"); String sql = ""; if (list.equals("all")) { sql = "select * from product"; }else if(list==null){ response.sendRedirect("index.jsp"); } else { sql = "select * from product where " + list + "= '" + value + "'"; } String Db_user="root"; String user_password="hythzx"; String port="3307"; String Datebase="ebook"; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { } try { con=DriverManager.getConnection("jdbc:mysql://localhost:"+port+"/"+Datebase+"??useUnicode=true&characterEncoding=UTF-8", Db_user, user_password); state = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); rs = state.executeQuery(sql); } catch (SQLException ex) { } //在这里判断结果集的个数 rs.last(); int row=rs.getRow(); int maxpage=(row%10==0)?(row/10):(row/10+1); String nowpage=(String)request.getParameter("nowpage"); int nowpage_int=1; if(nowpage==null){ } else{ nowpage_int=Integer.valueOf(nowpage)+1; } rs.absolute((nowpage_int-1)*10+1); out.println("nowpage_int="+nowpage_int); for(int i=0;i<10;i++){ out.print("<tr>"); out.print("<td>" + rs.getString(list_name[0]) + "</td>"); out.print("<td>" + rs.getString(list_name[1]) + "</td>"); out.print("<td>" + rs.getString(list_name[2]) + "</td>"); out.print("<td>" + rs.getFloat(list_name[3]) + "</td>"); out.print("<td>" + rs.getInt(list_name[4]) + "</td>"); out.print("<td>" + rs.getString(list_name[5]) + "</td>"); out.print("<td>" + rs.getString(list_name[6]) + "</td>"); %><td><input type="button" value="加入购物车" onclick="do_cart('cart.jsp','<%=rs.getInt("Id")%>')"></td> <td><input type="button" value="查看详情" onclick="do_cart('show.jsp','<%=rs.getInt("Id")%>')"></td> <% try{ if(!rs.next()) break; } catch(Exception e){ } out.print("</tr>"); } rs.close(); state.close(); con.close(); %> </table><br><br> <table width="249" border="1" align="center"> <tr> <td width="90">当前页:<%=nowpage_int%>/<%=maxpage%></td> <td width="61"><a href="put_result.jsp?nowpage=<%=nowpage_int-1%>&value=<%=value%>&list=<%=list%>" class="mydiv">上一页</a></td> <td width="60"><a href="put_result.jsp?nowpage=<%=nowpage_int+1%>&value=<%=value%>&list=<%=list%>">下一页</a></td> </tr> </table>