Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)
生活随笔
收集整理的這篇文章主要介紹了
Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
package cn.bdqn.mhouse.util;import java.util.ArrayList;
import java.util.List;import cn.bdqn.mhouse.entity.House;/***
*
* 項(xiàng)目名稱:mhouse
* 類(lèi)名稱:Page
* 類(lèi)描述: 分頁(yè)的工具類(lèi)
* 創(chuàng)建人:Mu Xiongxiong
* 創(chuàng)建時(shí)間:2017-3-17 下午1:04:02
* 修改人:Mu Xiongxiong
* 修改時(shí)間:2017-3-17 下午1:04:02
* 修改備注:
* @version
**/
public class Page {private int pageSize=3; //頁(yè)大小private int pageIndex=0; //當(dāng)前頁(yè)號(hào)private int totalPageCount=0; //總頁(yè)數(shù)private int record=0; //記錄總數(shù)private Integer nextPage; //下一頁(yè)private Integer prePage; //上一頁(yè)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;}//得到開(kāi)始記錄數(shù)public int getSartRow(){return (pageIndex-1)*pageSize;}//得到結(jié)束記錄數(shù)public int getEndRow(){return pageSize;}public int getPageSize() {return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;}public int getPageIndex() {return pageIndex;}//得到當(dāng)前頁(yè)public void setPageIndex(int pageIndex) {this.pageIndex = pageIndex;//下一頁(yè)setNextPage();//上一頁(yè)setPrePage();}public int getTotalPageCount() {return totalPageCount;}//總頁(yè)數(shù)public void setTotalPageCount() {int totalP = record % getPageSize() == 0 ? record / getPageSize() :record/ getPageSize() + 1;this.totalPageCount = totalP;}public int getRecord() {return record;}//總記錄數(shù)public void setRecord(int record) {this.record = record;//設(shè)置總頁(yè)數(shù)setTotalPageCount();}public Integer getNextPage() {return nextPage;}//設(shè)置下一頁(yè)public void setNextPage() {this.nextPage = this.pageIndex+1;}public Integer getPrePage() {return prePage;}//設(shè)置上一頁(yè)public void setPrePage() {this.prePage =this.pageIndex-1;if(this.prePage<1){this.prePage=1;}}}
總結(jié)
以上是生活随笔為你收集整理的Mybatis+mysql动态分页查询数据案例——分页工具类(Page.java)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 现在笔记本电脑什么配置够用呀?什么处理器
- 下一篇: Source Defense联合创始人解