zoukankan      html  css  js  c++  java
  • 封装分页查询的工具类utils----PageTool

    public class PageTool {

    private int currentPage;//当前页码

    private int pageSize;//每页显示的条数

    private int totalCount;//总记录数(查询数据库)

    private int totalPages;//总页数(计算)

    private int prePage;//上一页

    private int nextPage;//下一页

    private int startIndex;//每页第一条记录的起始下标(计算)

    public PageTool(int totalCount, String currentPage) {

    this.totalCount = totalCount;

    initCurrentPage(currentPage);

    this.pageSize=3;//页容量自定义,可以修改

    initTotalPages();//计算总页数

    initPrePage();//上一页

    initNextPage();//下一页

    initStartIndex();//每页第一条记录的超始下标

    }

    //给当前页码初始化

    private void initCurrentPage(String currentPage) {

    if (currentPage==null) {

    this.currentPage=1;

    }else {

    this.currentPage=Integer.valueOf(currentPage);

    }

    }

    //计算总页数

    private void initTotalPages() {

    this.totalPages=(totalCount%pageSize==0)?(totalCount/pageSize):(totalCount/pageSize+1);

    }

    //上一页

    private void initPrePage() {

    if (currentPage==1) {

    this.prePage=1;

    }else {

    this.prePage=currentPage-1;

    }

    }

    //下一页

    private void initNextPage() {

    if (currentPage==totalPages) {

    this.nextPage=totalPages;

    }else {

    this.nextPage=currentPage+1;

    }

    }

    //每页第一条记录的起始下标

    private void initStartIndex() {

    this.startIndex=pageSize*(currentPage-1);

    }

    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 getTotalPages() {

    return totalPages;

    }

    public void setTotalPages(int totalPages) {

    this.totalPages = totalPages;

    }

    public int getCurrentPage() {

    return currentPage;

    }

    public void setCurrentPage(int currentPage) {

    this.currentPage = currentPage;

    }

    public int getPrePage() {

    return prePage;

    }

    public void setPrePage(int prePage) {

    this.prePage = prePage;

    }

    public int getNextPage() {

    return nextPage;

    }

    public void setNextPage(int nextPage) {

    this.nextPage = nextPage;

    }

    public int getStartIndex() {

    return startIndex;

    }

    public void setStartIndex(int startIndex) {

    this.startIndex = startIndex;

    }

    }

  • 相关阅读:
    MD5,SHA1,SHA256,SHA512等常用加密算法
    Encoding.GetEncoding 编码列表
    Form开发小技巧
    全国分河流水系流域边界及河流数据水系及主要流域分界图
    建筑物轮廓自然保护区城市AOI水土保持水资源水文建成区生态功能分区矢量数据shptabdwgcdr
    坐标转换一些
    mysql 查询语言使用 lisoaring
    lisoaring python 字符串 编码
    全国各省乡镇街道边界行政区划矢量地图shpmapinfocad最新20101112131415 161718
    写第一篇 随笔
  • 原文地址:https://www.cnblogs.com/masterhxh/p/13732140.html
Copyright © 2011-2022 走看看