zoukankan      html  css  js  c++  java
  • Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)

    package cn.bdqn.mhouse.util;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import cn.bdqn.mhouse.entity.House;
    
    /**
     * 
    *    
    * 项目名称:mhouse   
    * 类名称:Page   
    * 类描述:   分页的工具类
    * 创建人:Mu Xiongxiong  
    * 创建时间:2017-3-17 下午1:04:02   
    * 修改人:Mu Xiongxiong   
    * 修改时间:2017-3-17 下午1:04:02   
    * 修改备注:   
    * @version    
    *
     */
    public class Page {
    	private int pageSize=3;            //页大小
    	private int pageIndex=0;           //当前页号
    	private int totalPageCount=0;      //总页数
    	private int record=0;              //记录总数
    	private Integer nextPage;          //下一页
    	private Integer prePage;           //上一页
    	private List<House> houseList=new ArrayList<House>();     //房屋信息的集合
    	
    	
    
    	/**    
    	 * @author Mu Xiongxiong       
    	 * @created 2017-3-17 下午10:04:41 
    	 * @return type 
    	 */
    	
    	public List<House> getHouseList() {
    		return houseList;
    	}
    
    	/**     
    	 * @author Mu Xiongxiong      
    	 * @created 2017-3-17 下午10:04:41         
    	 * @param houseList   
    	 */
    	public void setHouseList(List<House> houseList) {
    		this.houseList = houseList;
    	}
    
    	//得到开始记录数
    	public int getSartRow(){
    		return (pageIndex-1)*pageSize;
    	}
    	
    	//得到结束记录数
    	public int getEndRow(){
    		return pageSize;
    	}
    
    	public int getPageSize() {
    		return pageSize;
    	}
    
    	public void setPageSize(int pageSize) {
    		this.pageSize = pageSize;
    	}
    
    	public int getPageIndex() {
    		return pageIndex;
    	}
    
    	//得到当前页
    	public void setPageIndex(int pageIndex) {
    		this.pageIndex = pageIndex;
    		//下一页
    		setNextPage();
    		//上一页
    		setPrePage();
    	}
    
    	public int getTotalPageCount() {
    		return totalPageCount;
    	}
    
    	//总页数
    	public void setTotalPageCount() {
    		int totalP = record % getPageSize() == 0 ? record / getPageSize() :
    			record/ getPageSize() + 1;
    		this.totalPageCount = totalP;
    	}
    
    	public int getRecord() {
    		return record;
    	}
    	
    	//总记录数
    	public void setRecord(int record) {
    		this.record = record;
    		//设置总页数
    		setTotalPageCount();
    	}
    
    	public Integer getNextPage() {
    		return nextPage;
    	}
    
    	//设置下一页
    	public void setNextPage() {
    		this.nextPage = this.pageIndex+1;
    		
    	}
    
    	public Integer getPrePage() {
    		return prePage;
    	}
    
    	//设置上一页
    	public void setPrePage() {
    		this.prePage =this.pageIndex-1;
    		if(this.prePage<1){
    			this.prePage=1;
    		}
    	}
    	
    	
    
    }
    

  • 相关阅读:
    Rust 1.40.0 发布
    Rust程序交叉编译到aarch64(armv8)目标
    中西的根本区别:理性和感性 贺刚
    使用Rust加速Python
    让你的Python代码更快运行的 5 种方法
    Python基于pyCUDA实现GPU加速并行计算功能入门教程
    用 Psyco 让 Python 运行得像 C 一样快
    illuminate/routing 源码分析之注册路由
    php利用32进制实现对id加密解密
    微信小程序支付全问题解决
  • 原文地址:https://www.cnblogs.com/a1111/p/12816323.html
Copyright © 2011-2022 走看看