Java Web Paging class sharing

Source: Internet
Author: User

Paging class Sharing:

Package Com.hcj.util;import Java.util.arraylist;import Java.util.list;import org.apache.struts2.json.annotations.json;//page-type public class Page<e> {private int totals;//total number of queries private LIST&L T  E> biglist; Total record set private list<e> smalllist;  When the page displays the recordset private int currentpage = 1;  Current page private int pages; Total pages private int pageSize = 8; Number of records per page private int privious; Prev private int Next; Next private Boolean firstpage = false;//First private Boolean lastpage = false; Last page public int gettotals () {return totals;} public void settotals (int totals) {this.totals = totals;} @JSON (serialize=false) public list<e> getbiglist () {return biglist;} public void Setbiglist (list<e> biglist) {this.biglist = biglist;}        Public list<e> getsmalllist () {this.smalllist = new arraylist<e> (); for (int i = (currentPage-1) * pageSize; (I < currentpage* pageSize) && (i < totals); i++) {Smalllist.add (BigliSt.get (i)); } return smalllist;} public void Setsmalllist (list<e> smalllist) {this.smalllist = smalllist;} public int getcurrentpage () {return currentpage;} public void setcurrentpage (int currentpage) {this.currentpage = currentpage;}        public int getpages () {if (totals% PageSize = = 0) {pages = totals/pagesize;        } else {pages = totals/pagesize + 1; }return pages;} public void setpages (int pages) {this.pages = pages;} public int getpagesize () {return pageSize;} public void setpagesize (int pageSize) {this.pagesize = pageSize;}    public int getprivious () {if (currentpage! = 1) {privious = currentPage-1;    }else{privious = 1; }return privious;} public void setprivious (int privious) {this.privious = privious;}    public int GetNext () {if (CurrentPage! = GetPages ()) {next = currentpage + 1;    }else{next = currentpage; }return Next;} public void Setnext (int next) {This.next = next;} public Boolean isfirstpage () {if (currentpage == 1) {FirstPage = true; }return FirstPage;} public void Setfirstpage (Boolean firstpage) {this.firstpage = FirstPage;}    public Boolean islastpage () {if (currentpage = = GetPages ()) {lastpage = true; }return LastPage;} public void Setlastpage (Boolean lastpage) {this.lastpage = LastPage;} Public page () {super ();//TODO auto-generated constructor stub}//input total results, current page and size per page (default is 8 pages) public page (list<e> biglist, int currentpage, int pageSize) {super (); this.biglist = Biglist;this.currentpage = Currentpage;this.pagesize = PA gesize;//set Total, this step is important this.settotals (Biglist.size ());} Public Page (list<e> biglist, int currentpage) {super (); this.biglist = Biglist;this.currentpage = CurrentPage;            This.settotals (Biglist.size ());} }


Java Web Paging class sharing

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.