81,092
社区成员
发帖
与我相关
我的任务
分享
package com.psit.struts.common;
public class Page {
/**
* 当前页
*/
private int currentPageNo;
/**
*下一页
*/
private int nextPageNo;
/**
* 上一页
*/
private int prePageNo;
/**
* 第一页
*/
private int firstPageNo;
/**
* 最后一页
*/
private int lastPageNo;
/**
* 页大小
*/
private int pageSize ;
/**
* 多少行
*/
private int rowsCount;
/**
* 多少页
*/
private int pageCount;
/**
* 初始化
* @param rowsCount
* @param pageSize
*/
public Page(int rowsCount,int pageSize)
{
this.rowsCount = rowsCount;
this.pageSize = pageSize;
}
public int getCurrentPageNo() {
if(this.currentPageNo > this.getLastPageNo())
{
this.setCurrentPageNo(this.getLastPageNo());
}
if(this.currentPageNo < this.getFirstPageNo())
{
this.setCurrentPageNo(this.getFirstPageNo());
}
return currentPageNo;
}
public void setCurrentPageNo(int currentPageNo) {
this.currentPageNo = currentPageNo;
}
/**
* 获得下一页码
* @return
*/
public int getNextPageNo() {
this.nextPageNo = this.currentPageNo + 1;
if(this.nextPageNo>this.getPageCount())
{
this.nextPageNo = this.getPageCount();
}
return nextPageNo;
}
/**
* 获得总页数
* @return
*/
public int getPageCount() {
if(this.rowsCount % this.pageSize == 0)
{
this.pageCount = this.rowsCount / this.pageSize;
}
else
{
this.pageCount = (this.rowsCount / this.pageSize) + 1;
}
return pageCount;
}
/**
* 获得前一页码
* @return
*/
public int getPrePageNo() {
this.prePageNo = this.currentPageNo - 1;
if(this.prePageNo <=0 )
{
this.prePageNo = 1;
}
return prePageNo;
}
/**
* 获得第一页
* @return
*/
public int getFirstPageNo() {
this.firstPageNo = 1;
return firstPageNo;
}
/**
* 获得最后一页
* @return
*/
public int getLastPageNo() {
this.lastPageNo = this.getPageCount();
return lastPageNo;
}
public int getPageSize() {
return pageSize;
}
public int getRowsCount() {
return rowsCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
}