📄 nextformtag.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;
public class NextFormTag extends TagSupport {
private static final long serialVersionUID = 5543378892830363703L;
private String action;
private ListTag listTag;
private String method;
public NextFormTag() {
action = null;
listTag = null;
method = "POST";
}
/**
*
* @throws JspException
*/
public int doStartTag() throws JspException {
listTag = (ListTag) TagSupport.findAncestorWithClass(this, ListTag.class);
if(listTag == null)
throw new JspTagException("NextFormTag: nextForm tag not inside listtag");
if (!listTag.hasNextForm())
return SKIP_BODY;
if ((listTag.pageIndex + 1) >= listTag.totalPages)
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.getNextParam() + "\" value=\"true\" />");
} catch (IOException e) {
System.out.print("NextFormTag: error printing <form> tag");
}
return 1;
}
/**
*
* @throws JspException
*/
public int doEndTag() throws JspException {
if (listTag.hasNextForm())
try {
JspWriter jspWriter = pageContext.getOut();
jspWriter.println("</form>");
} catch (IOException e) {
System.out.print("NextFormTag: error printing <form> tag");
}
return 6;
}
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 + -