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

📄 page.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
字号:
package com.yuanchung.sales.util;

import java.util.List;

public class Page {
	private int currentPage;// 当前页码

	private int rowsPerPage;// 每页记录数

	private String path;// 请求路径

	private int allCount;// 总记录数

	private List list;// 数据

	public Page(String path, int allCount, int currentPage, int rowsPerPage,
			List mmList) {
		this.path = path;
		this.allCount = allCount;
		this.currentPage = currentPage;
		this.rowsPerPage = rowsPerPage;
		this.list = mmList;
	}

	public int getAllCount() {
		return allCount;
	}

	public void setAllCount(int allCount) {
		this.allCount = allCount;
	}

	public int getRowsPerPage() {
		return rowsPerPage;
	}

	public void setRowsPerPage(int rowsPerPage) {
		this.rowsPerPage = rowsPerPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

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

	public List getList() {
		return list;
	}

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

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getAllPage() {
		return (this.allCount - 1) / this.rowsPerPage + 1;
	}

	public String getPageBar(){
		StringBuffer bar = new StringBuffer();
		bar.append("<%@ page language='java' pageEncoding='UTF-8'%>");
		bar.append("<div class='tableHead'>");
		if(this.currentPage<=1){
			bar.append("首页&nbsp;&nbsp;&nbsp;上页");
		}else{
			bar.append("<a href=\""+path+"&currentPage=1\">首页</a>&nbsp;&nbsp;&nbsp;");
			bar.append("<a href=\""+path+"&currentPage="+(this.currentPage-1)+"\">上页</a>");
		}
		bar.append("&nbsp;&nbsp;&nbsp;<select  name=\"xx\" onchange=\"forward(this.value)\">");
		for(int i=1;i<=this.getAllPage();i++){
			if(i==this.currentPage){
				bar.append("<option value='"+i+"' selected>"+i+"/"+this.getAllPage()+"</option>");
			}else{
				bar.append("<option value='"+i+"'>"+i+"/"+this.getAllPage()+"</option>");
			}
		}
		bar.append("</select></span>&nbsp;&nbsp;&nbsp;");
		if(this.currentPage>=this.getAllPage()){
			bar.append("下页&nbsp;&nbsp;&nbsp;尾页");
		}else{
			bar.append("<a href=\""+path+"&currentPage="+(this.currentPage+1)+"\">下页</a>&nbsp;&nbsp;&nbsp;");
			bar.append("<a href=\""+path+"&currentPage="+(this.getAllPage())+"\">尾页</a>");
		}		
		bar.append("<span align=\"left\" style='margin-left:10px'>每页"+this.rowsPerPage+"条/共"+this.getAllPage()+"页   共"+this.allCount+"条</span></div>");
		bar.append("<script>");
		bar.append("function forward(page){");
		bar.append(" location.href='"+path+"&currentPage='+page;");
		bar.append("}");
		bar.append("</script>");
		return bar.toString();		
	}
}

⌨️ 快捷键说明

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