Java-分页工具类

2021/7/11 20:08:10

本文主要是介绍Java-分页工具类,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

分页工具类

package com.etc.util;
 
import java.util.List;
 
/**分页工具类*/
public class Page<T> {
     // 总页数
    private int totalPageCount = 1;
    // 页面大小,即每页显示记录数
    private int pageSize = 0;
    // 记录总数
    private int totalCount = 0;
    // 当前页号
    private int currPageNo = 1;
    // 每页数据集合
    private List<T> list;
  
    public List<T> getList() {
        return list;
    }
  
    public void setList(List<T> list) {
        this.list = list;
    }
  
    public int getCurrPageNo() {
        if (totalPageCount == 0)
            return 0;
        return currPageNo;
    }
  
    public void setCurrPageNo(int currPageNo) {
        if (this.currPageNo > 0)
            this.currPageNo = currPageNo;
    }
  
    public int getTotalPageCount() {
        return totalPageCount;
    }
  
    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }
  
    public int getPageSize() {
        return pageSize;
    }
  
    public void setPageSize(int pageSize) {
        if (pageSize > 0)
            this.pageSize = pageSize;
    }
  
    public int getTotalCount() {
        return totalCount;
    }
  
    public void setTotalCount(int totalCount) {
        if (totalCount > 0) {
            this.totalCount = totalCount;
            // 计算总页数
            totalPageCount = this.totalCount % pageSize == 0 ? (this.totalCount / pageSize)
                    : this.totalCount / pageSize + 1;
        }
    }
}

 



这篇关于Java-分页工具类的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程