分页封装类
定义系统常量
Constant.java
<span style="font-size:18px;">public static final String PAGE_SIZE = "10";</span>
PageResult.java
<span style="font-size:18px;">/**
* 分页封装类
* @param <T>
*/
public class PageResult<T> {
/** 结果数据集合 **/
private List<T> resultList = new ArrayList<T>();
/** 数据总量 **/
private int totalCount;
/**
* 总页数
*/
private int pageTotal;
/**
* 当前页
*/
private int pageOffSet;
/**
*
* 默认每页10条数据
*/
private int pageSize = Integer.parseInt(Constant.PAGE_SIZE);
public PageResult(){
}
public PageResult(int pageSize){
this.pageSize = pageSize;
}
public List<T> getResultList() {
return resultList;
}
public void setResultList(List<T> resultList) {
this.resultList = resultList;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getPageTotal() {
if (totalCount % pageSize == 0) {
pageTotal = totalCount / pageSize;
} else {
pageTotal = totalCount / pageSize + 1;
}
return pageTotal;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageOffSet() {
return pageOffSet;
}
public void setPageOffSet(int pageOffSet) {
this.pageOffSet = pageOffSet;
}
}</span>