if标签的自定义

1)tld文件内容
<tag>
    <name>if</name>
    <tag-class>defineLables.iftag</tag-class>
    <body-content>scriptless</body-content>
    <attribute>
        <name>test</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>
2if标签处理器类
public class iftag extends SimpleTagSupport{
    private boolean test;

    public void setTest(boolean test) {
        this.test = test;
    }

    @Override
    public void doTag() throws JspException, IOException {
        if(test){
            this.getJspBody().invoke(null);
        }
    }
}
3)jsp文件内容
 <ctag:if test="true">
        条件成立
    </ctag:if>

猜你喜欢

转载自blog.csdn.net/newVenues/article/details/70786514