您的位置:首页 > 其它

SSH与SSM学习之SSH实现CRM练习02——客户列表02_PageBean

2017-12-01 00:46 411 查看
SSH与SSM学习之SSH实现CRM练习02客户列表02_PageBean
一说明

二PageBean

三源码下载

SSH与SSM学习之SSH实现CRM练习02——客户列表02_PageBean

一、说明

为了分页方便,我们需要写一个和分页相关的类。需要的字段如下

//当前页数
private Integer currentPage;
//总记录数
private Integer totalCount;
//每页显示条数
private Integer pageSize;
//总页数
private Integer totalPage;
//分页列表数据
private List list;


二、PageBean

package com.qwm.ssh_crm.utils;

import java.util.List;

/**
* @author:qiwenming
* @date:2017/11/5 0005   0:21
* @description:
* 分页使用的bean
*/
public class PageBean {
//当前页数
private Integer currentPage;
//总记录数
private Integer totalCount;
//每页显示条数
private Integer pageSize;
//总页数
private Integer totalPage;
//分页列表数据
private List list;

public PageBean(Integer currentPage, Integer totalCount, Integer pageSize) {
this.currentPage = currentPage;
this.totalCount = totalCount;
this.pageSize = pageSize;

//如果页面没有指定显示哪一页,那么显示第一页
if(this.currentPage==null){
this.currentPage = 1;
}

//如果每页显示条数没有指定,默认每页显示5条
if(this.pageSize==null){
this.pageSize = 5;
}

//计算总页数
this.totalPage = (this.totalCount+this.pageSize-1)/this.pageSize;

//判断当前页是否超出了范围
//不能小于1 不能大于最大页数
if(this.currentPage<1){
this.currentPage = 1;
}else if(this.currentPage>this.totalPage){
this.currentPage = this.totalPage;
}
}

//计算起始索引
public int getStart(){
return (this.currentPage-1)*this.pageSize;
}

public Integer getCurrentPage() { return currentPage; }

public void setCurrentPage(Integer currentPage) { this.currentPage = currentPage; }

public Integer getTotalCount() { return totalCount; }

public void setTotalCount(Integer totalCount) { this.totalCount = totalCount; }

public Integer getPageSize() { return pageSize; }

public void setPageSize(Integer pageSize) { this.pageSize = pageSize; }

public Integer getTotalPage() { return totalPage; }

public void setTotalPage(Integer totalPage) { this.totalPage = totalPage; }

public List getList() { return list; }

public void setList(List list) { this.list = list; }
}


三、源码下载

https://github.com/wimingxxx/ssh_crm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: