js| Paging
JSP is as follows:
**********************
<%@ page language= "java" import= "java.util.*,java.sql.*"%>
<%@ page contenttype= "text/html;charset=gb2312"%>
<jsp:usebean id= "cn" scope= "page" class= "Myconnection.conn"/><!--The bean that references the database operation, do it yourself, and don't repeat it here-->
<%
int curpage=1;//Current Page
int page_record=20;//The number of records displayed per page
Use the following method (SQL query complete, fast)
Curpage=integer.parseint (Request.getparameter ("page"));//Get the passed value, the page that needs to be displayed
ResultSet rs=cn.rsexecutequery (' Select top ' +page_record+ ' * FROM TableName where ID is not in (select Top +) + (curpage*page_re Cord) + "ID from tablename ORDER BY id DESC" () Order by id DESC ");
This query statement gets the 1000 pages of 20 records that you want to display, and the general idea is--the subquery excludes all records before the records that need to be displayed, and the parent queries the remaining records in descending order
while (Rs.next) {
Out.println (Rs.getint ("id"). toString ());
}
Rs.close ();
%>