S2SH框架中java实现jsp页面分页
1、接口分页类
package com.broadengate.business.service.iface;
import java.util.List;
@SuppressWarnings("rawtypes")
public interface PageClass {
/**
* 初始化分页信息
*/
public abstract void init();
/**
* 以下判断页的信息,只需getter方法(is方法)即可
* @return
*/
public abstract boolean isFirstPage();
public abstract boolean isLastPage();
public abstract boolean isHasPreviousPage();
public abstract boolean isHasNextPage();
public abstract List getList();
public abstract void setList(List list);
public abstract int getTotalPage();
public abstract void setTotalPage(int totalPage);
public abstract int getCurrentPage();
public abstract void setCurrentPage(int currentPage);
public abstract int getPageSize();
public abstract void setPageSize(int pageSize);
public abstract void setFirstPage(boolean isFirstPage);
public abstract void setLastPage(boolean isLastPage);
public abstract void setHasPreviousPage(boolean hasPreviousPage);
public abstract void setHasNextPage(boolean hasNextPage);
public abstract int getAllCount();
public abstract void setAllCount(int allCount);
public abstract int getStartPage();
public abstract void setStartPage(int startPage);
public abstract int getEndPage();
public abstract void setEndPage(int endPage);
public abstract int countTotalPage(final int pageSize,final int allRow);
public abstract int countOffset(final int pageSize,final int currentPage);
public abstract int countCurrentPage(int page);
}
2、实现分页类
package com.broadengate.business.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.broadengate.business.service.iface.PageClass;
/**
* @ClassName: PageClass
* @Description: 分页类
* @author 邓伟
* @date 2010-11-10 上午13:12:49
*/
@Service
@SuppressWarnings("rawtypes")
public class PageClassImpl implements PageClass {
private List list; //集合
private int allCount;
private int totalPage; //总页数
private int currentPage=0; //当前页
private int pageSize; //每页显示多少条数
private int endPageIndex;
public int getEndPageIndex() {
return endPageIndex;
}
public void setEndPageIndex(int endPageIndex) {
this.endPageIndex = endPageIndex;
}
private boolean isFirstPage; //是否为第一页
private boolean isLastPage; //是否为最后一页
private boolean hasPreviousPage; //是否有上一页
private boolean hasNextPage; //是否有下一页
//2010-12-1 添加 起始行 终止行
private int startPage;//起始行
private int endPage; //终止行
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#init()
*/
public void init() {
this.totalPage = totalPage;
this.isFirstPage = isFirstPage;
this.isLastPage = isLastPage;
this.hasPreviousPage = hasPreviousPage;
this.hasNextPage = hasNextPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isFirstPage()
*/
public boolean isFirstPage() {
return currentPage==1;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isLastPage()
*/
public boolean isLastPage() {
return currentPage==totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isHasPreviousPage()
*/
public boolean isHasPreviousPage() {
retur