Java分页查询工具类
生活随笔
收集整理的這篇文章主要介紹了
Java分页查询工具类
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public class PageList<T> {private int totalpage; //總頁數 private int totalcount; //總記錄數 private int currentpage; //當前頁 private int pagesize; //每頁的數量 private int firstpage; //第一頁private int lastpage; //最后一頁private int prepage; //上一頁private int nextpage; //下一頁private boolean isprepage; //是否有上一頁private boolean isnextpage; //是否有下一頁private List<T> result = new ArrayList<T>(); /*** 構造方法描述* * @param result 返回結果* @param currentpage 當前頁數* @param pagesize 每頁的數量 * @param totalcount 總記錄數 */public PageList(List<T> result,int currentpage, int pagesize, int totalcount){this.result = result;this.currentpage = currentpage; this.pagesize = pagesize; this.totalcount = totalcount; if(pagesize == 0 || totalcount == 0){return ;}if(currentpage < 1){ this.currentpage = 1; } if (totalcount % pagesize == 0) {this.totalpage = totalcount / pagesize;} else {this.totalpage = totalcount / pagesize + 1;}this.firstpage =1; this.lastpage = totalpage; if(this.currentpage > 1){ this.prepage = this.currentpage - 1; }else{ this.prepage = 1; } if(this.currentpage < totalpage){ this.nextpage = this.currentpage + 1; }else{ this.nextpage = totalpage; } if(this.currentpage <= 1){ this.isprepage = false; }else{ this.isprepage = true; } if(this.currentpage >= totalpage){ this.isnextpage = false; }else{ this.isnextpage = true; } }public int getTotalpage() {return totalpage;}public void setTotalpage(int totalpage) {this.totalpage = totalpage;}public int getTotalcount() {return totalcount;}public void setTotalcount(int totalcount) {this.totalcount = totalcount;}public int getCurrentpage() {return currentpage;}public void setCurrentpage(int currentpage) {this.currentpage = currentpage;}public int getPagesize() {return pagesize;}public void setPagesize(int pagesize) {this.pagesize = pagesize;}public int getFirstpage() {return firstpage;}public void setFirstpage(int firstpage) {this.firstpage = firstpage;}public int getLastpage() {return lastpage;}public void setLastpage(int lastpage) {this.lastpage = lastpage;}public int getPrepage() {return prepage;}public void setPrepage(int prepage) {this.prepage = prepage;}public int getNextpage() {return nextpage;}public void setNextpage(int nextpage) {this.nextpage = nextpage;}public boolean isIsprepage() {return isprepage;}public void setIsprepage(boolean isprepage) {this.isprepage = isprepage;}public boolean isIsnextpage() {return isnextpage;}public void setIsnextpage(boolean isnextpage) {this.isnextpage = isnextpage;}public List<T> getResult() {return result;}public void setResult(List<T> result) {this.result = result;} }
?
轉載于:https://www.cnblogs.com/zhaojinhui/p/4981462.html
總結
以上是生活随笔為你收集整理的Java分页查询工具类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: urlrewrite伪静态 及多参数传递
- 下一篇: Effective Java阅读笔记——