package cn.itcast.customer.domain; |
import java.util.ArrayList; |
import java.util.List; |
/* |
* 代表分页显示的每一页 |
*/ |
public class Page { |
//集合,代表该页显式的记录 |
//查询数据库得到:select * from *** limit M,N |
//findCustomerByPage |
private List list = new ArrayList(); |
//总记录数 |
//查询数据库: findAllCustomerCount |
private int totalCount; |
//总页码 |
//总页码通过计算总记录数和页面大小得到 |
private int totalPage; |
//当前页码---> 第几页 |
//从JSP页面得到 |
private int currentPage; |
//页面大小 |
//定义常量 |
private int pageSize; |
//当前页面的起始记录数 |
//当前页面的起始记录数=(当前页码-1)*页面大小+1 |
private int startIndex; |
|
//定义一个URL --> 目的:可以对任意的集合实现分页 |
private String url; |
|
public Page( int pageNO, int pageSize){ |
this .currentPage = pageNO; |
this .pageSize = pageSize; |
|
//计算该页的起始记录数 ---> M |
this .startIndex = ( this .currentPage- 1 )* this .pageSize+ 1 ; |
} |
|
public String getUrl() { |
return url; |
} |
public void setUrl(String url) { |
this .url = url; |
} |
public List getList() { |
return list; |
} |
public void setList(List list) { |
this .list = list; |
} |
public int getTotalCount() { |
return totalCount; |
} |
public void setTotalCount( int totalCount) { |
this .totalCount = totalCount; |
} |
public int getTotalPage() { |
//总页码通过计算总记录数和页面大小得到 |
int mod = this .totalCount % this .pageSize; |
if (mod == 0 ){ |
this .totalPage = this .totalCount/ this .pageSize; |
} else { |
this .totalPage = this .totalCount/ this .pageSize + 1 ; |
} |
|
return totalPage; |
} |
public void setTotalPage( int totalPage) { |
this .totalPage = totalPage; |
} |
public int getCurrentPage() { |
return currentPage; |
} |
public void setCurrentPage( int currentPage) { |
this .currentPage = currentPage; |
} |
public int getPageSize() { |
return pageSize; |
} |
public void setPageSize( int pageSize) { |
this .pageSize = pageSize; |
} |
public int getStartIndex() { |
return startIndex; |
} |
public void setStartIndex( int startIndex) { |
this .startIndex = startIndex; |
} |
|
|
} |