Loading...

jqPaginator分页插件

如下图效果:

官方地址:http://jqpaginator.keenwon.com/

 

 

java后台代码Page对象:

/**
 * 
 * All Rights Reserved. 保留所有权利.
 */
package com.sh.portal.util;

/**
 * @Author: jsun
 * @Create: 2013-7-25 下午3:32:39
 * @Version: 1.0
 * @Description:
 */
public class PageUtil {
	
	public final static Integer PAGE_SIZE = 10;
	
	/**
	 * 每页显示条数
	 */
	private int pageSize;
	
	/**
	 * 页码
	 */
	private int pageNumber;
	
	/**
	 * 开始记录
	 */
	private int start;
	
	/**
	 * 总记录数
	 */
	private int totalRecords;
	
	/**
	 * 总页数
	 */
	private int totalPage;

	
	/**
	 * 
	 * @param pageNumber		页码
	 * @param pageSize	每页条数
	 * @param totalRecords	总记录数
	 */
	public PageUtil(int pageNumber, int pageSize, int totalRecords){
		if(pageSize == 0) {
			this.pageSize = PAGE_SIZE;
		}else{
			this.pageSize = pageSize;
		}
		
		setTotalRecords(totalRecords);
		
		this.pageNumber = DataFormat.parseInt(pageNumber, 1);
		if (this.pageNumber <= 0) {
			this.pageNumber = 1;
		} else if (this.pageNumber > totalPage && totalPage > 0) {
			this.pageNumber = totalPage;
		}
		if (totalPage == 0) {
			this.pageNumber = 1;
		}	
		
		this.start =  (this.pageNumber - 1) * this.pageSize;
	}
	
	public PageUtil(int pageNumber, int pageSize){
		this.pageSize = pageSize;
		this.pageNumber = DataFormat.parseInt(pageNumber, 1);
		this.start = (this.pageNumber - 1) * this.pageSize;
	}
	
	public PageUtil(){
		this.pageSize = PAGE_SIZE;
		this.pageNumber = 1;
		this.start = (this.pageNumber - 1) * this.pageSize;
	}
	
	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getStart() {
		this.start = (this.pageNumber - 1) * this.pageSize;
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		
		int temp = totalRecords % pageSize;
		
		if (temp == 0){
			this.totalPage = totalRecords / pageSize;
		}else{
			this.totalPage = totalRecords / pageSize + 1;
		}
		if(this.pageNumber < 1){
    		this.pageNumber = 1;
    	} else if(this.getTotalPage() < this.pageNumber){
    		this.pageNumber = this.totalPage;
    	}
		this.totalRecords = totalRecords;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
	    if(this.pageNumber > 0){
	        this.start = (this.pageNumber - 1) * this.pageSize;
	    }
		this.pageSize = pageSize;
	}
	
	
	
}

  

    posted @ 2015-08-21 16:50  微笑阳光哈*_*  阅读(974)  评论(0编辑  收藏  举报