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

📄 pagecontroller.java

📁 一个java写的网上购物系统
💻 JAVA
字号:
package com.hb.myshop.tools;

import java.util.ArrayList;
import java.util.List;

public class PageController
{
	private List bigList; //传入的要分页的集合
	private List smallList; //在页面上显示的集合
	private int currentPageIndex = 1;//当前页面编号
	private int countPerPage = 5;//每页显示的条数
	private int pageCount;//页面总的个数
	private int recordCount;//总的记录条数
	private int prePageIndex;//上一页的编号
	private int nextPageIndex;//下一页的编号
	private boolean firstPage;//是否是第一页
	private boolean lastPage;//是否是最后一页
	public void setCurrentPageIndex(int currentPageIndex) 
	{
		this.currentPageIndex = currentPageIndex;
		this.smallList = new ArrayList();
		
		this.prePageIndex = this.currentPageIndex - 1;
		this.nextPageIndex = this.currentPageIndex + 1;
		
		if(this.currentPageIndex == 1)
		{
			this.firstPage = true;
		}
		else
		{
			this.firstPage = false;
		}
		
		if(this.currentPageIndex == this.pageCount)
		{
			this.lastPage = true;
		}
		else
		{
			this.lastPage = false;
		}
		//将要显示的大的集合分成每个页面上显示的集合
		for(int i = (this.currentPageIndex - 1) * this.countPerPage;
		 		i<this.currentPageIndex * this.countPerPage && i<this.recordCount;
		 		i++)
		{
			this.smallList.add(this.bigList.get(i));
		}
	}
	public List getBigList() {
		return bigList;
	}
	public void setBigList(List bigList) {
		this.bigList = bigList;
		if(this.bigList!=null){
			this.recordCount = this.bigList.size();
		}
		else{
			this.recordCount=0;
		}
		if(this.recordCount % this.countPerPage == 0)
		{
			this.pageCount = this.recordCount / this.countPerPage;
		}
		else
		{
			this.pageCount = this.recordCount / this.countPerPage + 1;
		}
	}
	public int getCountPerPage() {
		return countPerPage;
	}
	public void setCountPerPage(int countPerPage) {
		this.countPerPage = countPerPage;
	}
	public int getCurrentPageIndex() {
		return currentPageIndex;
	}
	public boolean isFirstPage() {
		return firstPage;
	}
	public void setFirstPage(boolean firstPage) {
		this.firstPage = firstPage;
	}
	public boolean isLastPage() {
		return lastPage;
	}
	public void setLastPage(boolean lastPage) {
		this.lastPage = lastPage;
	}
	public int getNextPageIndex() {
		return nextPageIndex;
	}
	public void setNextPageIndex(int nextPageIndex) {
		this.nextPageIndex = nextPageIndex;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public List getSmallList() {
		return smallList;
	}
	public void setSmallList(List smallList) {
		this.smallList = smallList;
	}
	public int getPrePageIndex() {
		return prePageIndex;
	}
	public void setPrePageIndex(int prePageIndex) {
		this.prePageIndex = prePageIndex;
	}
	
}

⌨️ 快捷键说明

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