zoukankan      html  css  js  c++  java
  • 核心代码之分页

    public class PageResult {

     //总记录数
     private long totalCount;
     //当前页号
     private int pageNo;
     //总页数
     private int totalPageCount;
     //页大小
     private int pageSize;
     //列表记录
     private List items;
     
     //计算总页数
     public PageResult(long totalCount, int pageNo, int pageSize, List items) {
      this.items = items==null?new ArrayList():items; //如果items是空的话 就new一个否者直接给他值,防止空指针异常
      this.totalCount = totalCount;
      this.pageSize = pageSize;
      if(totalCount != 0){ // 总记录数 非 0 时
       //计算总页数 
       int tem = (int)totalCount/pageSize;  //总页数 = 总记录数  除以  页大小
       this.totalPageCount = (totalCount%pageSize==0)?tem:(tem+1); //如果总记录数  % 页大小 == 0则 赋值页数 , 否则+1,因为有多余的记录
       this.pageNo = pageNo;
      } else {
       this.pageNo = 0;
      }
     }
     
     public long getTotalCount() {
      return totalCount;
     }
     public void setTotalCount(long totalCount) {
      this.totalCount = totalCount;
     }
     public int getPageNo() {
      return pageNo;
     }
     public void setPageNo(int pageNo) {
      this.pageNo = pageNo;
     }
     public int getTotalPageCount() {
      return totalPageCount;
     }
     public void setTotalPageCount(int totalPageCount) {
      this.totalPageCount = totalPageCount;
     }
     public int getPageSize() {
      return pageSize;
     }
     public void setPageSize(int pageSize) {
      this.pageSize = pageSize;
     }
     public List getItems() {
      return items;
     }
     public void setItems(List items) {
      this.items = items;
     }
     
    }

  • 相关阅读:
    几个论坛上看到的2015小米笔试题
    Line(扩展欧几里得)
    MapReduce编程之倒排索引
    annotation(@Retention@Target)详解
    【JEECG技术文档】JEECG平台对外接口JWT应用文档V3.7.2
    jeecg 模糊查询
    jeecg下实现自动默认模糊查询
    The packaging for this project did not assign a file to the build artifact
    Maven添加本地Jar包
    maven 如何引入本地jar包
  • 原文地址:https://www.cnblogs.com/zzzz97/p/6748721.html
Copyright © 2011-2022 走看看