⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageinfo.java

📁 ssh 实例spring对hibernate的封装
💻 JAVA
字号:
package com.ssh.struts.util;

import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * 分页功能类
 * @author T.Xin.Jun
 *
 */
public class PageInfo {
	/**
	 * 一页中显示的记录条数
	 */
	private int pageCount = 3;
	/**
	 * 当前的页数
	 */
	private int currentPage;
	/**
	 * 总的页数
	 */
	private int totalPage;
	/**
	 * 总的记录条数
	 */
	private int totalCount;
	/**
	 * 标识,是否有下一页
	 */
	private boolean hasNextPage = true;
	/**
	 * 标识,是否有上一页
	 */
	private boolean hasPreviousPage = true;
	/**
	 * 一页中数据
	 */
	private List pageData;
	/**
	 * 查询的种类
	 */
	private String type;
	/**
	 * 查询的关键字
	 */
	private String keyword;

	/**
	 * @return the pageCount
	 */
	public int getPageCount() {
		return pageCount;
	}

	/**
	 * @param pageCount the pageCount to set
	 */
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	/**
	 * @return the currentPage
	 */
	public int getCurrentPage() {
		return currentPage;
	}

	/**
	 * @param currentPage the currentPage to set
	 */
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
		if(this.currentPage < 1){
			this.setCurrentPage(1);
		}
		if(this.currentPage > this.totalPage){
			this.setCurrentPage(this.totalPage);
		}
		if(this.currentPage == 1){
			this.setHasPreviousPage(false);
		}
		if(this.currentPage == this.totalPage){
			this.setHasNextPage(false);
		}
	}

	/**
	 * @return the totalPage
	 */
	public int getTotalPage() {
		return totalPage;
	}

	/**
	 * @param totalPage the totalPage to set
	 */
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	/**
	 * @return the totalCount
	 */
	public int getTotalCount() {
		return totalCount;
	}

	/**
	 * @param totalCount the totalCount to set
	 */
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
		int totalPage = 1;
		if((this.totalCount % this.pageCount) == 0){
			totalPage = this.totalCount / this.pageCount;
		}else{
			totalPage = (this.totalCount / this.pageCount) + 1;
		}
		if(totalPage == 0){
			totalPage = 1;
		}
		this.setTotalPage(totalPage);
	}

	/**
	 * @return the hasNextPage
	 */
	public boolean isHasNextPage() {
		return hasNextPage;
	}

	/**
	 * @param hasNextPage the hasNextPage to set
	 */
	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}

	/**
	 * @return the hasPreviousPage
	 */
	public boolean isHasPreviousPage() {
		return hasPreviousPage;
	}

	/**
	 * @param hasPreviousPage the hasPreviousPage to set
	 */
	public void setHasPreviousPage(boolean hasPreviousPage) {
		this.hasPreviousPage = hasPreviousPage;
	}

	/**
	 * @return the pageData
	 */
	public List getPageData() {
		return pageData;
	}

	/**
	 * @param pageData the pageData to set
	 */
	public void setPageData(List pageData) {
		this.pageData = pageData;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the keyword
	 */
	public String getKeyword() {
		return keyword;
	}

	/**
	 * @param keyword the keyword to set
	 */
	public void setKeyword(String keyword) {
		try {
			this.keyword = new String(keyword.getBytes(), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -