java分页类

阅读更多
public class Pagination {

	private PageParam pageParam;
	private List list;
	
	public Pagination() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Pagination(PageParam pageParam, List list) {
		super();
		this.pageParam = pageParam;
		this.list = list;
	}
	public PageParam getPageParam() {
		return pageParam;
	}
	public void setPageParam(PageParam pageParam) {
		this.pageParam = pageParam;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}	
	
}

 

    

public class PageParam {

	private int pageFirst = 0;
	private int pageNum = 1;
	private int pageSize = 10;
	private int totalCount = 0;
	private int totalPage = 0;
	
	public PageParam(int pageNum, int pageSize, int totalCount, int totalPage) {
		super();
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalCount = totalCount;
		this.totalPage = totalPage;
	}
	public PageParam() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public int getPageFirst() {
		return pageFirst;
	}
	public void setPageFirst(int pageFirst) {
		this.pageFirst = pageFirst;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	
}

 

   

public class PageUtil {

	public static PageParam get(int pageNum,int pageSize){
		PageParam p = new PageParam();
		int pageFirst = (pageNum-1)*pageSize;
		p.setPageFirst(pageFirst);
		p.setPageNum(pageNum);
		p.setPageSize(pageSize);
		return p;
	}
	public static PageParam get(int pageNum,int pageSize,int totalCount){
		int pageFirst = (pageNum-1)*pageSize;
		int totalPage = (totalCount-1)/pageSize+1;
		PageParam p = new PageParam();
		p.setPageFirst(pageFirst);
		p.setPageNum(pageNum);
		p.setPageSize(pageSize);
		p.setTotalCount(totalCount);
		p.setTotalPage(totalPage);
		return p;
	}
}

 

你可能感兴趣的:(page,java)