分页工具类PageBean

Posted 永旗狍子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分页工具类PageBean相关的知识,希望对你有一定的参考价值。


public class PageBean implements Serializable {
    //1 当前页码
    private Integer pageIndex;
    //2 每页显示行数
    private Integer pageSize;
    //3 总页数
    private Integer totalPage;
    //4 数据总行数
    private Integer totalCount;
    //5 起始行数
    private Integer startRows;
    //参数(当前页码,每页显示行数,数据总行数)
    public PageBean(Integer pageIndex, Integer pageSize, Integer totalCount) {
        this.totalCount = totalCount;
        if (pageSize < 1) {
            this.pageSize = 5;
        } else {
            this.pageSize = pageSize;
        }
        //总页数
        this.totalPage = this.totalCount % this.pageSize == 0 ? this.totalCount / this.pageSize : (this.totalCount / this.pageSize) + 1;
        //this.totalPage=(int)Math.ceil(this.totalCount/(double)this.pageSize);
        //设置当前页码
        if (pageIndex < 1) {
            this.pageIndex = 1;
        } else if (pageIndex > this.totalPage) {
            this.pageIndex = this.totalPage;
        } else {
            this.pageIndex = pageIndex;
        }
        //计算起始行
        this.startRows = (this.pageIndex - 1) * this.pageSize;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    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 Integer getTotalCount() {
        return totalCount;
    }

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

    public Integer getStartRows() {
        return startRows;
    }

    public void setStartRows(Integer startRows) {
        this.startRows = startRows;
    }
}

 

以上是关于分页工具类PageBean的主要内容,如果未能解决你的问题,请参考以下文章

分页PageBean类

分页实体类:PageBean

java分页三个类 PageBean ResponseUtil StringUtil

pageBean实现分页

Javaweb查询客户&分页部分代码

分页,条件查询