首页>代码>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  LV9 2024年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日
不正经的90后程序猿  LV1 2022年12月10日
qiuqiuqiu111  LV4 2022年12月5日
13112360  LV2 2022年9月27日
hunterwang  LV4 2022年8月26日
最近浏览更多
renjunyou  LV10 6月2日
13188140406 3月12日
暂无贡献等级
微信网友_7311533327257600 2024年12月25日
暂无贡献等级
571818771  LV3 2024年12月16日
wzd031105  LV2 2024年12月6日
Yuehao 2024年6月26日
暂无贡献等级
ma406805131  LV19 2024年6月18日
2640660246 2024年5月10日
暂无贡献等级
pangzhihui  LV14 2024年4月15日
惺惺惜惺惺嘻嘻嘻 2024年3月29日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友