本文共 691 字,大约阅读时间需要 2 分钟。
- 新建OutTag类
- OutTag类详细代码 ``` package bid.zhazhapan.fims.tag; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; public class OutTag extends BodyTagSupport { private boolean out;// 判断是否输出标签体的属性 // 通过set方法获得页面out的属性值 public void setOut(boolean out) { this.out = out; } // 覆盖doStartTag()方法 public int doStartTag() throws JspException { if (out == true) { return this.EVAL_BODY_INCLUDE; } else { return this.SKIP_BODY; } } } ```
- ``` <?xml version="1.0" encoding="UTF-8"?> 1.0demo/demooutputbid.zhazhapan.fims.tag.OutTagJSPouttruetrue ```
- 新建test.jsp来测试标签 ``` Insert title hereHello everybody ```
转载于:https://www.cnblogs.com/zhazhapan/p/java_jsp_tag_with_body.html