A page JSP paging Method

Source: Internet
Author: User
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"/> <! -- Reference the bean for database operations and complete it by yourself. I will not go into details here -->
<%
Int curpage = 1; // current page
Int page_record = 20; // number of records displayed on each page
// Use the following method (SQL query is completed, and the speed is fast)
Curpage = integer. parseint (request. getparameter ("page"); // obtain the passed value, the page to be displayed
Resultset rs = cn. rsexecutequery ("select top" + page_record + "* From tablename where id not in (select top" + (curpage * page_record) + "id from tablename order by id desc) order by id desc ");
// This query statement returns the 20 records on the 1000 page to be displayed. The general idea is that subqueries exclude all records before the records to be displayed, the parent query sorts the remaining records in descending order.
While (Rs. Next ){
Out. println (Rs. getint ("ID"). tostring ());
}
Rs. Close ();
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.