码迷,mamicode.com
首页 > 其他好文 > 详细

PageBean

时间:2018-05-25 01:36:06      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:不能   lis   current   显示   util   gets   ota   start   ret   

 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

标签:不能   lis   current   显示   util   gets   ota   start   ret   

原文地址:https://www.cnblogs.com/ZhangHaiBK/p/9086047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!