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

📄 page.java

📁 用STRUTS ,HIBERNATE, SPRING 三种框架整合做的实战项目
💻 JAVA
字号:
package com.ghy.data.book;

public class Page {
	private String categoryId = null;//记录属于哪个书类
	private int totalRows = 0; // 记录总数
	private int totalPages = 0; // 总页数
	private int pageSize = 3; // 每页显示数据条数,默认为10条记录
	private int currentPage = 1; // 当前页数
	private boolean hasPrevious = false; // 是否有上一页
	private boolean hasNext = false; // 是否有下一页
	
	public Page() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * @return the categoryId
	 */
	public String getCategoryId() {
		return categoryId;
	}

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

	/**
	 * @return the totalRows
	 */
	public int getTotalRows() {
		return totalRows;
	}
	/**
	 * @param totalRows
	 *            the totalRows to set
	 */
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
		init(totalRows, pageSize);
	}
	/**
	 * @return the totalPages
	 */
	public int getTotalPages() {
		return totalPages;
	}
	/**
	 * @param totalPages
	 *            the totalPages to set
	 */
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}
	/**
	 * @param pageSize
	 *            the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	/**
	 * @return the currentPage
	 */
	public int getCurrentPage() {
		return currentPage;
	}
	/**
	 * @param currentPage
	 *            the currentPage to set
	 */
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	/**
	 * @return the hasPrevious
	 */
	public boolean isHasPrevious() {
		return hasPrevious;
	}
	/**
	 * @param hasPrevious
	 *            the hasPrevious to set
	 */
	public void setHasPrevious(boolean hasPrevious) {
		this.hasPrevious = hasPrevious;
	}
	/**
	 * @return the hasNext
	 */
	public boolean isHasNext() {
		return hasNext;
	}
	/**
	 * @param hasNext
	 *            the hasNext to set
	 */
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public void init(int totalRows, int pageSize) {
		this.totalRows = totalRows;
		this.pageSize = pageSize;
		if (totalRows % pageSize != 0)
			totalPages = totalRows / pageSize + 1;
		else
			totalPages = totalRows / pageSize;
		refresh(); // 刷新当前页面信息
	}
	// 跳到第一页

	public void first() {
		currentPage = 1;
		this.setHasPrevious(false);
		refresh();
	}
	// 取得上一页(重新设定当前页面即可)

	public void previous() {
		currentPage--;
		refresh();
	}
	public void next() {
		if (currentPage < totalPages) {
			currentPage++;
		}
		refresh();
	}

	// 跳到最后一页

	public void last() {
		currentPage = totalPages;
		this.setHasNext(false);
		refresh();
	}
	public void refresh() {
		if (totalPages <= 1) {
			hasPrevious = false;
			hasNext = false;
		} else if (currentPage == 1) {
			hasPrevious = false;
		    hasNext = true;
		} else if (currentPage == totalPages) {
			hasPrevious = true;
			hasNext = false;
		} else {
			hasPrevious = true;
			hasNext = true;
		}
	}
}

⌨️ 快捷键说明

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