发布人:小菜鸟
自定义标签心得:
1显示页面(jsp):<%@ taglib uri="/helloworld" prefix="mytag" %>
2web.xml:
/helloworld
/WEB-INF/helloworld.tld
3helloword.tld文件
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
1.0
1.2
untitled1
helloworld
untitled1.HelloWorldTag
empty
4新建java文件模型:
package untitled1;
import java.io.IOException;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.http.HttpSession;
public class HelloWorldTag extends TagSupport {
public HelloWorldTag() {
}
public int doStartTag() throws JspTagException{
JspWriter out=pageContext.getOut();
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspTagException{
return EVAL_PAGE;
}
}
自定义标签参数总结:
java文件加入:
private String parm1=null;
public void setParm1(String parm1)
{
this.parm1 = parm1;
}
tld文件加入:
parm3
false
false