Mybatis+mysql动态分页查询数据案例——分页工具类(Page.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;}}}
總結
以上是生活随笔為你收集整理的Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 现在笔记本电脑什么配置够用呀?什么处理器
- 下一篇: Mybatis+mysql动态分页查询数