Paging Here I use the example of querying user information from a user table to illustrate its usage:
1. Compile the Pageresultset.java file into a class file and put it into your web
In the Web-inf/classes/com/youngor/util directory of the application, you can modify the package name accordingly.
2. In your action class:
First remove the data from the business Process logic class (ArrayList or vector format)
Userbo userbo=new Userbo ();
Collection data=userbo.findusers ();//Example method
Then get the current page curpage and the number of records per page pagesize
int curpage = Integer.parseint (Request.getparameter ("Cur_page"));
int pagesize=15;
Then generate the Pageresultset object
Pageresultset dataList = new Pageresultset (data, curpage, pageSize);
Request.setattribute ("Userslist", userslist);
Attention:
1. If you feel that the paging toolbar does not meet your requirements, you can use the public method in the Pageresultset class
The one (), previous (), Next (), last () Customize your own toolbars, and you can also define multiple style toolbars in Pageresultset.
2. The Gettoolbar (string url) method accepts parameters with a query string, such as "list_users.do?class_id=1".
Pageresultset.java
Package com.youngor.util;
Import java.util.*;
/**
* <p>Title:PageResultSet</p>
*
* <p>description: Pagination class </p>
*
* <p>copyright:copyright (c) 2004</p>
*
* <p>company:youngor-studio (http://www.54youngor.com) </p>
* @author: Woovipo
* @version 1.0
*/
public class Pageresultset {
/**
* Paging Data
*/
Private Collection data = null;
/**
* Current Page
*/
private int curpage;
/**
* Number of records displayed per page
*/
private int pageSize;
/**
* Record number of rows
*/
private int rowscount;
/**
* Page number
*/
private int PageCount;
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.