Java Web page sharing and Java Web page sharing
Share by page:
Package com. hcj. util; import java. util. arrayList; import java. util. list; import org. apache. struts2.json. annotations. JSON; // public class Page of the paging class <E> {private int totals; // The total number of queried private lists <E> bigList; // total record set private List <E> smallList; // when the page displays the record set private int currentPage = 1; // the current page private int pages; // total number of pages private int pageSize = 8; // number of records per page private int privious; // Previous Page private int next; // next page private B Oolean firstPage = false; // private boolean lastPage = false on the first 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} // enter the summary result, current Page and size per Page (8 pages by default) public Page (List <E> bigList, int currentPage, int pageSize) {super (); this. bigList = bigList; this. currentPage = currentPage; this. pageSize = pageSize; // set total. this step is very important. setTotals (bigList. size ();} public Page (List <E> bigList, int currentPage) {super (); this. bigList = bigList; this. currentPage = currentPage; this. setTotals (bigList. size ());}}