package com.demo.struts2.util;
import java.util.ArrayList;
import java.util.List;
public class Pager {
// 页面大小
protected int[] pageSizeList = { 10, 25, 50, 100, 200, 300, 500 };
// 一页显示的记录数
protected int pageSize = Constants.pageSize;
// 当前页码
protected int pageNo = Constants.pageNo;
// 记录总数
protected int rowCount = 0;
// 总页数
protected int pageCount = 1;
// 起始行数
protected int startIndex = 1;
// 结束行数
protected int endIndex = 1;
protected int firstPageNo = 1;
protected int prePageNo = 1;
protected int nextPageNo = 1;
protected int lastPageNo = 1;
// 结果集存放List
protected List resultList;
public Pager(int pageSize, int pageNo, int rowCount, List resultList) {
this.pageSize = pageSize;
this.pageNo = pageNo;
this.rowCount = rowCount;
this.resultList = resultList;
if (rowCount % pageSize == 0) {
this.pageCount = rowCount / pageSize;
} else {
this.pageCount = rowCount / pageSize + 1;
}
this.startIndex = pageSize * (pageNo - 1);
this.endIndex = this.startIndex + resultList.size();
this.lastPageNo = this.pageCount;
if (this.pageNo > 1) this.prePageNo = this.pageNo -1;
if (this.pageNo == this.lastPageNo){
this.nextPageNo = this.lastPageNo;
} else {
this.nextPageNo = this.pageNo + 1;
}
}
public Object[] getPageSizeIndexs() {
List result = new ArrayList(pageSizeList.length);
for (int i = 0; i < pageSizeList.length; i++) {
result.add(String.valueOf(pageSizeList[i]));
}
Object[] indexs = (result.toArray());
return indexs;
}
public Object[] getPageNoIndexs() {
List result = new ArrayList(pageCount);
for (int i = 0; i < pageCount; i++) {
result.add(String.valueOf(i + 1));
}
Object[] indexs = (result.toArray());
return indexs;
}
public int getEndIndex() {
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int[] getPageSizeList() {
return pageSizeList;
}
public void setPageSizeList(int[] pageSizeList) {
this.pageSizeList = pageSizeList;
}
public List getResultList() {
return resultList;
}
public void setResultList(List resultList) {
this.resultList = resultList;
}
public int getRowCount() {
return rowCount;
}
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getFirstPageNo() {
return firstPageNo;
}
public void setFirstPageNo(int firstPageNo) {
this.firstPageNo = firstPageNo;
}
public int getLastPageNo() {
return lastPageNo;
}
public void setLastPageNo(int lastPageNo) {
this.lastPageNo = lastPageNo;
}
public int getNextPageNo() {
return nextPageNo;
}
public void setNextPageNo(int nextPageNo) {
this.nextPageNo = nextPageNo;
}
public int getPrePageNo() {
return prePageNo;
}
public void setPrePageNo(int prePageNo) {
this.prePageNo = prePageNo;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Struts2 Spring Hibernate应用系统源码(Demo) (100个子文件)
logo6.bmp 4KB
logo7.bmp 4KB
logo5.bmp 4KB
logo8.bmp 4KB
Pager.class 4KB
RegisterAction.class 3KB
UserDAO.class 3KB
LoginAction.class 2KB
BaseAction.class 2KB
AbstractUser.class 2KB
UserDAO$1.class 2KB
UserDAO$2.class 2KB
LogoutAction.class 1KB
LoggingInterceptor.class 1KB
Constants.class 1017B
RegExpression.class 1012B
User.class 542B
IUserDAO.class 437B
.classpath 2KB
styles.css 603B
Thumbs.db 21KB
fielderror.ftl 1KB
fielderror.ftl 1KB
actionmessage.ftl 168B
actionmessage.ftl 168B
actionerror.ftl 155B
actionerror.ftl 155B
spring.jar 2.57MB
struts2-core-2.0.9.jar 2.1MB
hibernate3.jar 1.6MB
freemarker-2.3.8.jar 784KB
commons-collections-3.1.jar 546KB
xwork-2.0.4.jar 445KB
antlr-2.7.2.jar 350KB
log4j-1.2.12.jar 350KB
cglib-nodep-2.1_2.jar 317KB
dom4j-1.6.jar 306KB
sitemesh-2.3.jar 178KB
ognl-2.6.11.jar 164KB
commons-validator-1.3.0.jar 117KB
commons-beanutils-1.6.jar 116KB
mysql-2.0.4.jar 107KB
commons-dbcp.jar 105KB
commons-chain-1.1.jar 88KB
oro-2.0.8.jar 64KB
ehcache-1.1.jar 46KB
commons-logging-api-1.1.jar 44KB
commons-pool-1.2.jar 41KB
commons-logging-1.0.4.jar 37KB
commons-logging.jar 37KB
jta.jar 9KB
struts2-spring-plugin-2.0.9.jar 8KB
Pager.java 3KB
AbstractUser.java 3KB
RegisterAction.java 2KB
UserDAO.java 2KB
BaseAction.java 2KB
LoginAction.java 1KB
RegExpression.java 1KB
Constants.java 1016B
User.java 687B
LogoutAction.java 618B
IUserDAO.java 403B
LoggingInterceptor.java 341B
frame.jsp 2KB
register.jsp 1KB
login.jsp 963B
welcome.jsp 641B
MANIFEST.MF 39B
.mymetadata 286B
logo2.png 23KB
logo4.png 20KB
logo3.png 2KB
com.genuitec.eclipse.j2eedt.core.prefs 1KB
.project 1KB
ApplicationResources_zh_CN.properties 12KB
ApplicationResources_zh_CN.properties 12KB
ApplicationResources.properties 8KB
ApplicationResources_en.properties 8KB
ApplicationResources.properties 8KB
ApplicationResources_en.properties 8KB
ApplicationResources_temp.properties 8KB
ApplicationResources_temp.properties 8KB
struts.properties 8KB
struts.properties 8KB
log4j.properties 978B
log4j.properties 978B
commons-logging.properties 198B
commons-logging.properties 198B
simplelog.properties 60B
simplelog.properties 60B
sitemesh-decorator.tld 3KB
sitemesh-page.tld 2KB
applicationContext.xml 3KB
web.xml 2KB
User.hbm.xml 884B
User.hbm.xml 884B
struts.xml 866B
struts.xml 866B
decorators.xml 190B
共 100 条
- 1
oO临时工Oo
- 粉丝: 413
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页