PageBean - 分页查询工具类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PageBean - 分页查询工具类相关的知识,希望对你有一定的参考价值。
基础的PageBean参考
package com.hao.dto; import java.util.List; public class PageBean<T> { //当前页 private Integer currentPage; //每页记录数 private Integer pageSize; //总记录数 private Integer totalCount; //总页数 private Integer totalPage; //开始索引 private Integer startIndex; //数据 private List<T> data; public PageBean(Integer currentPage, Integer pageSize, Integer totalCount){ this.currentPage = currentPage; this.pageSize = pageSize; this.totalCount = totalCount; if(this.currentPage == null){ //如页面没有指定显示那一页.显示第一页. this.currentPage = 1; } if(this.pageSize == null){ //如果每页显示条数没有指定,默认每页显示3条 this.pageSize = 3; } this.totalPage = (totalCount-1)/pageSize + 1; //判断当前页数是否超出范围 //不能小于1 if(this.currentPage < 1){ this.currentPage = 1; } //不能大于总页数 if(this.currentPage > this.totalPage){ this.currentPage = this.totalPage; } //根据当前页和每页显示条数计算起始索引 this.startIndex = (currentPage-1) * pageSize; } public int getCurrentPage() { return currentPage; } public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { this.totalCount = totalCount; } public int getTotalPage() { return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public int getStartIndex() { return startIndex; } public void setStartIndex(int startIndex) { this.startIndex = startIndex; } public List<T> getData() { return data; } public void setData(List<T> data) { this.data = data; } }
以上是关于PageBean - 分页查询工具类的主要内容,如果未能解决你的问题,请参考以下文章