分頁Page基類
阿新 • • 發佈:2018-12-31
import java.util.List; public class Page<T> { //頁碼 private Integer pageno; //每頁顯示的條數 private Integer pagesize; //總頁碼 private Integer totalno; //總共有多少條資料 private Integer totalsize; //總資料集合 private List<T> datas; public Page(Integer pageno, Integer pagesize) { if (pagesize<=0) { this.pagesize=10; }else { this.pagesize=pagesize; } if (pageno<=0) { this.pageno=1; }else { this.pageno = pageno; } } public Integer getPageno() { return pageno; } public void setPageno(Integer pageno) { this.pageno = pageno; } public Integer getPagesize() { return pagesize; } public void setPagesize(Integer pagesize) { this.pagesize = pagesize; } public Integer getTotalno() { return totalno; } public void setTotalno(Integer totalno) { this.totalno = totalno; } public Integer getTotalsize() { return totalsize; } public void setTotalsize(Integer totalsize) { this.totalsize = totalsize; this.totalno=(totalsize%pagesize==0)?(totalsize/pagesize):(totalsize/pagesize+1); } public List<T> getDatas() { return datas; } public void setDatas(List<T> datas) { this.datas = datas; } public Integer getIndexStart() { return (pageno-1)*pagesize; } }