PageBean
Posted zhanghaibk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PageBean相关的知识,希望对你有一定的参考价值。
1 package cn.itcast.utils; 2 3 import java.util.List; 4 5 public class PageBean { 6 //当前页数 7 private Integer currentPage; 8 //总记录数 9 private Integer totalCount; 10 //每页显示条数 11 private Integer pageSize; 12 //总页数 13 private Integer totalPage; 14 //分页列表数据 15 private List list; 16 public PageBean(Integer currentPage, Integer totalCount, Integer pageSize) { 17 this.totalCount = totalCount; 18 19 this.pageSize = pageSize; 20 21 this.currentPage = currentPage; 22 23 if(this.currentPage == null){ 24 //如页面没有指定显示那一页.显示第一页. 25 this.currentPage = 1; 26 } 27 28 if(this.pageSize == null){ 29 //如果每页显示条数没有指定,默认每页显示3条 30 this.pageSize = 3; 31 } 32 33 //计算总页数 34 this.totalPage = (this.totalCount+this.pageSize-1)/this.pageSize; 35 36 //判断当前页数是否超出范围 37 //不能小于1 38 if(this.currentPage < 1){ 39 this.currentPage = 1; 40 } 41 //不能大于总页数 42 if(this.currentPage > this.totalPage){ 43 this.currentPage = this.totalPage; 44 } 45 46 } 47 //计算起始索引 48 public int getStart(){ 49 return (this.currentPage-1)*this.pageSize; 50 } 51 52 public Integer getCurrentPage() { 53 return currentPage; 54 } 55 public void setCurrentPage(Integer currentPage) { 56 this.currentPage = currentPage; 57 } 58 public Integer getTotalCount() { 59 return totalCount; 60 } 61 public void setTotalCount(Integer totalCount) { 62 this.totalCount = totalCount; 63 } 64 public Integer getPageSize() { 65 return pageSize; 66 } 67 public void setPageSize(Integer pageSize) { 68 this.pageSize = pageSize; 69 } 70 public Integer getTotalPage() { 71 return totalPage; 72 } 73 public void setTotalPage(Integer totalPage) { 74 this.totalPage = totalPage; 75 } 76 public List getList() { 77 return list; 78 } 79 public void setList(List list) { 80 this.list = list; 81 } 82 83 84 85 86 87 88 }
以上是关于PageBean的主要内容,如果未能解决你的问题,请参考以下文章