首页>代码>JSP+Servlet+MySQL或SQLServer实现增删改查,搜索,分页功能>/MySql实现显示分页/src/com/mstf/bean/Page.java
package com.mstf.bean;

import java.util.List;

/**
 * 分页bean
 * @author
 *
 */
public class Page {
	// 人为规定的
	private int pageSize ;// 每页显示多少条数据
	// 通过页面传递过来得
	private int currentPage = 1;// 默认显示第一页的数据
	// 通过查询数据库得来的
	private int rowCount ;// 总行数
	// 通过计算来的
	private int pageCount ;// 总页数
	
	private List list ;// 每页数据的集合
	
	private int startIndex ;// 开始的页码
	
	private int endIndex ;// 结束的页码
	
	public Page() {}
	public Page(int pageSize,int currentPage,int rowCount,List list) {
		this.pageSize = pageSize ;
		this.currentPage = currentPage ;
		this.rowCount = rowCount ;
		this.list = list ;
		pageCount = (rowCount+pageSize-1)/pageSize ;
		if(pageCount <=3) {
			startIndex = 1 ;
			endIndex = pageCount ;
		} else {
			// 1,2,3,4,5,6
			startIndex = currentPage -1 ;
			endIndex = currentPage + 1 ;
			if(startIndex <= 1) {
				startIndex = 1 ;
				endIndex = 3 ;
			}
			if(endIndex >= pageCount) {
				endIndex = pageCount ;
				startIndex = pageCount -2 ;
			}
			
		}
	}
	

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}

	public int getEndIndex() {
		return endIndex;
	}

	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}
	
	
	
}
最近下载更多
xiongwei11231  LV8 1月15日
321170193  LV6 2023年11月12日
另类清晨  LV8 2023年9月19日
2017143155  LV12 2023年7月19日
include  LV8 2022年12月31日
gshnbb  LV9 2022年12月11日
Java开发工程师_初心  LV1 2022年12月10日
qiuqiuqiu111  LV4 2022年12月5日
13112360  LV2 2022年9月27日
hunterwang  LV4 2022年8月26日
最近浏览更多
pangzhihui  LV12 4月15日
暂无贡献等级
sssz123 2月21日
暂无贡献等级
王冰冰0001 1月15日
暂无贡献等级
xiongwei11231  LV8 1月15日
2131234536546  LV7 1月4日
沈从文  LV2 2023年12月31日
微信网友_6802139027345408  LV2 2023年12月31日
qwerewqss 2023年12月30日
暂无贡献等级
hxy19991216  LV4 2023年12月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友