JSP自定义标签的实现过程
1、编写标签处理类HelloTag(实现javax.servlet.jsp.tagext.Tag类)
package cn.itcast.tag;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
public class HelloTag implements Tag {
private PageContext pageContext;
private Tag tag;
public int doEndTag() throws JspException {
try {
pageContext.getOut().print(\"hello world!\");
} catch (IOException e) {
e.printStackTrace();
}
return Tag.EVAL_PAGE;
}
public int doStartTag() throws JspException {
return Tag.SKIP_BODY;
}
public Tag getParent() {
return null;
}
public void release() {
}
public void setPageContext(PageContext arg0) {
this.pageContext = arg0;
}
public void setParent(Tag arg0) {
this.tag = arg0;
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>