package com.ht.util;
public class BasePage{
public static final Integer DEFAULT_CURRENT=1; //默认显示第一页
public static final Integer DEFAULT_PAGE_NUM=10;//默认显示10条记录
protected Integer pageFirRecord=0; //当前页第一条记录
protected Integer currentPage=1; //当前页数
protected Integer totalPages; //总页数
protected Integer totalRecord; //总记录数
protected Integer showRecordNum=DEFAULT_PAGE_NUM; //每页显示记录数
protected Integer showPageNum; //当前页显示的记录数量
protected Integer prePage=1;
protected Integer nexePage=1;
public BasePage(){
}
public BasePage(Integer currentPage,Integer totalRecord){
this.setTotalRecord(totalRecord);
this.setTotalPages();
this.setCurrentPage(currentPage);
this.setShowPageNum();
this.setPageFirRecord();
this.setPrePage();
this.setNexePage();
}
/**
* 重载
* @param currentPage
* @param totalRecord
* @param showRecordNum
*/
public BasePage(Integer currentPage,Integer totalRecord,int showRecordNum){
this.setTotalRecord(totalRecord);
this.setShowRecordNum(showRecordNum);
this.setTotalPages();
this.setCurrentPage(currentPage);
this.setShowPageNum();
this.setPageFirRecord();
this.setPrePage(); //计算前一页页码
this.setNexePage(); //计算下一页页码
}
public Integer getPrePage() {
return prePage;
}
public void setPrePage() {
this.prePage = currentPage-1;
}
public Integer getNexePage() {
return nexePage;
}
public void setNexePage() {
if(currentPage==totalPages){ //如果当前页码为总页码,即最后一页
this.nexePage = 0; //返回0
}else{
this.nexePage = currentPage+1;
}
if(totalPages==0){ //如果总页数为0,怎么返回0;
this.nexePage = 0;
}
}
public Integer getShowPageNum() {
return showPageNum;
}
public void setShowPageNum() { //当前页显示的记录数量
if(currentPage*showRecordNum-totalRecord>0){
this.showPageNum = totalRecord-(currentPage-1)*showRecordNum;
}else{
this.showPageNum=showRecordNum;
}
}
public Integer getShowRecordNum() {
return showRecordNum;
}
public void setShowRecordNum(Integer showRecordNum) {
if(showRecordNum==0){ //如果记录数为0,则默认为5
this.showRecordNum=5;
}else{
this.showRecordNum = showRecordNum;
}
}
public Integer getTotalPages() {
return totalPages;
}
public void setTotalPages() { //计算总页数
if(totalRecord%showRecordNum==0){
this.totalPages = totalRecord/showRecordNum;
}else{
this.totalPages = totalRecord/showRecordNum+1;
}
}
public Integer getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(Integer totalRecord) {
this.totalRecord = totalRecord;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
if(currentPage==0||currentPage<0){
currentPage=1;
}
if(currentPage>totalPages&&totalPages!=0){ //2010年8月27日增加,
this.currentPage=totalPages; //当前页大于总页数时为总页数,并且保证不存在记录时不出错,即totalPages!=0
}else if(totalPages==0){
this.currentPage=1;
}else{
this.currentPage = currentPage;
}
}
public void setPageFirRecord() { //第一条记录所在集合的标号,比实际排数少一
this.pageFirRecord = (getCurrentPage()-1)*showRecordNum;
}
public Integer getPageFirRecord() {
return pageFirRecord;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
struts 2 分页+Freemarker结合的分页
共35个文件
jar:7个
java:5个
class:5个
3星 · 超过75%的资源 需积分: 10 29 下载量 177 浏览量
2011-01-17
17:48:35
上传
评论
收藏 3.1MB RAR 举报
温馨提示
这是一个struts2.0+Freemarker结合的分页,不需要连接数据即可运行,很强大的一个分页组件
资源推荐
资源详情
资源评论
收起资源包目录
Pagination.rar (35个子文件)
Pagination
.project 1KB
.settings
.jsdtscope 500B
org.eclipse.core.resources.prefs 169B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 303B
WebRoot
css
pagination.css 2KB
WEB-INF
common-pagination.ftl 3KB
paginationShow.ftl 2KB
web.xml 697B
lib
javassist-3.7.ga.jar 531KB
xwork-core-2.2.1.jar 997KB
freemarker-2.3.16.jar 860KB
struts2-core-2.2.1.jar 755KB
commons-fileupload-1.2.1.jar 56KB
ognl-3.0.jar 224KB
commons-io-1.3.2.jar 86KB
classes
com
ht
action
PaginationAction.class 2KB
db
StudentDB.class 1KB
service
PaginationService.class 1KB
entity
Student.class 735B
util
BasePage.class 3KB
struts.xml 444B
index.jsp 421B
META-INF
MANIFEST.MF 36B
image
onOver.png 2KB
js
jquery-1.3.2.min.js 56KB
.myeclipse
src
com
ht
action
PaginationAction.java 1KB
db
StudentDB.java 501B
service
PaginationService.java 668B
entity
Student.java 341B
util
BasePage.java 3KB
struts.xml 444B
.classpath 918B
共 35 条
- 1
资源评论
- chenzengzhe2012-08-16还可以,不过在没有数据的时候就会出现0,1这样子的bug。
兰舟轻帆
- 粉丝: 1250
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功