?? pageutil.java
字號:
package com.cucu.tapestry.util;
import java.io.Serializable;
/**
* 一個查詢相關的分頁數(shù)據(jù)
*
* @author 絕情酷哥
* @version 1.0
*/
public class PageUtil implements Serializable {
/**
* 當前第幾頁
*/
int currentPageNum = 1;
/**
* 每頁多少條記錄
*/
int perPageNum = 10; //默認每頁10條記錄
/**
* 總共有多少條記錄,總記錄數(shù)
*/
int totalCount = 0;
/**
* 共有多少頁*
*/
int pageCount = 1;
/**
* @return 得到當前頁碼
*/
public int getCurrentPageNum() {
if (this.currentPageNum > this.pageCount) {
this.currentPageNum = this.pageCount;
} else if (this.currentPageNum < 1) {
this.currentPageNum = 1;
}
return currentPageNum;
}
/**
* 設置當前頁碼
*
* @param currentPageNum
*/
public void setCurrentPageNum(int currentPageNum) {
if (this.currentPageNum > this.pageCount) {
this.currentPageNum = this.pageCount;
} else if (this.currentPageNum < 1) {
this.currentPageNum = 1;
}
this.currentPageNum = currentPageNum;
}
/**
* @return 得到總記錄數(shù)
*/
public int getTotalCount() {
return totalCount;
}
/**
* 設置總記錄數(shù)
*
* @param totalCount
*/
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
this.doPageBreak();
}
/**
* @return 得到每頁記錄數(shù)
*/
public int getPerPageNum() {
return perPageNum;
}
/**
* 設置每頁記錄數(shù)
*
* @param perPageNum
*/
public void setPerPageNum(int perPageNum) {
this.perPageNum = perPageNum;
doPageBreak();
}
/**
* @return 返回總頁碼數(shù)
*/
public int getPageCount() {
return pageCount;
}
/**
* 計算分頁的總頁數(shù)
*/
public void doPageBreak() {
if (this.perPageNum > 0 && this.totalCount > 0) {
this.pageCount =
(int) Math.ceil(
((double) this.totalCount) / ((double) this.perPageNum));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -