pagetag.java

来自「企业管理信息系统 myeclipse+mysql+hibernate+stru」· Java 代码 · 共 65 行

JAVA
65
字号
package com.emis.dbservice.hibernate;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public final class pageTag extends TagSupport {
	private String actiondo;
	private int currentPage;
	private int maxPage;
	public String getAction() {
		return actiondo;
	}

	public void setAction(String action) {
		this.actiondo = action;
	}

	@Override
	public int doEndTag() throws JspException {
		JspWriter out = this.pageContext.getOut();
		try {
			out.println("<font size='2'>");
			if (this.currentPage == 1) {
				out.println("首页  上一页");
			} else {
				out.println("<a href='" + actiondo + ".do?direct=first'>"
						+ "首页</a>");
				out.println("&nbsp;&nbsp;");
				out.println("<a href='" + actiondo + ".do?direct=previous'>" + "上一页</a>");
			}
			if (this.currentPage > maxPage) {
				this.currentPage = maxPage;
			}
			if (this.currentPage == maxPage) {
				out.println("下一页 尾页");
			} else {
				out.println("<a href='" + actiondo + ".do?direct=next'>" + "下一页</a>");
				out.println("&nbsp;&nbsp;");
				out.println("<a href='" + actiondo + ".do?direct=last'>" + "尾页</a>");
			}
			out.println("</font>");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return this.EVAL_PAGE;
	}

	public int getCurrentPage() {
		return currentPage;
	}

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

	public int getMaxPage() {
		return maxPage;
	}

	public void setMaxPage(int maxPage) {
		this.maxPage = maxPage;
	}
}

⌨️ 快捷键说明

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