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

📄 prevformtag.java

📁 一个用struts tiles的在线影院web系统
💻 JAVA
字号:
package com.eline.common.taglib;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspTagException;
import java.io.IOException;
import javax.servlet.jsp.JspWriter;

/**
 * 
 * @author Lucifer
 *
 */
public class PrevFormTag extends TagSupport {

	private static final long serialVersionUID = 6123778929643047239L;

    private String action;
    private String method;
    private ListTag listTag;

    public PrevFormTag() {
        this.action = null;
        this.method = "POST";
	}

    /**
     * 
     */
	public int doStartTag() throws JspException {
        listTag = (ListTag)TagSupport.findAncestorWithClass(this, ListTag.class);
        if(listTag == null)
            throw new JspTagException("PrevFormTag: prevForm tag not inside in listTag");
        if(!listTag.hasPreviousForm())
            return SKIP_BODY;
        if(listTag.pageIndex <= 0)
            return SKIP_BODY;

        try {
			JspWriter jspWriter = pageContext.getOut();
			jspWriter.println("<form method=\"" + method + "\" action=\"" + action + "\">");
			jspWriter.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getPageIndexParam() + "\" value=\"" + (listTag.getPageIndex() - 1) + "\" />");
			jspWriter.println("	<input type=\"hidden\" name=\"" + listTag.getParamPrefix() + listTag.getPrevParam() + "\" value=\"true\" />");
		} catch (IOException ioexception) {
			System.out.print("PrevFormTag: error printing <form> tag");
		}
		return EVAL_BODY_INCLUDE;
	}

	/**
	 * 
	 */
	public int doEndTag() throws JspException {
        if(listTag.hasPreviousForm()) {
            try {
                JspWriter jspWriter = pageContext.getOut();
                jspWriter.print("</form>");
            } catch (IOException e) {
                System.out.print("PrevFormTag: error printing <form> tag");
            }
        }
        return EVAL_PAGE;
	}

	/**
	 * 
	 * @param action
	 */
	public void setAction(String action) {
		this.action = action;
	}

	public void setMethod(String method) {
		if(method != null && !method.equals("") && !method.equalsIgnoreCase("null"))
			this.method = method;
		else
			this.method = "POST";
	}
}

⌨️ 快捷键说明

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