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

📄 page.java

📁 实现留言薄和发表文章的功能
💻 JAVA
字号:
package com.test.bbs.service.impl;

import java.util.List;
/*
 * 翻页
 */
public class Page {
	private List items;//得到所有帖子

	private int totalCount;//总帖子数

	private int pageSize;//每一页显示的帖子数

	private int totalPageCount;//总页数

	private int currentPage;//当前页码

	public Page(List items, int totalCount, int pageSize, int currentPage) {
		this.items = items;
		this.totalCount = totalCount;
		this.pageSize = pageSize;
		this.currentPage = currentPage;

		this.totalPageCount = this.totalCount / this.pageSize;
		if (this.totalCount % this.pageSize != 0)
			this.totalPageCount++;
	}

	@Override
	public String toString() {
		return "totalCount=" + this.getTotalCount() + " pageSize=" + pageSize
				+ " totalPageCount=" + totalPageCount + " currentPage="
				+ currentPage + " items=" + items;
	}
//上一页
	public int getPrePage() {
		int i = this.currentPage - 1;
		if (i < 1)
			return 1;
		return i;
	}
//下一页
	public int getNextPage() {
		int i = this.currentPage + 1;
		if (i >= this.totalPageCount)
			return this.totalPageCount;
		return i;
	}
//当前页数
	public int getCurrentPage() {
		return currentPage;
	}

	public List getItems() {
		return items;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public int getTotalPageCount() {
		return totalPageCount;
	}
}

⌨️ 快捷键说明

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