public class IfTag extends SimpleTagSupport { private boolean test;
public void setTest(boolean test) { this.test = test; }
@Override public void doTag() throws JspException, IOException { // TODO Auto-generated method stub if(test)//如果有EL表达式就会先执行 this.getJspBody().invoke(null); else super.doTag();
} } |
<body> <% session.setAttribute("user","mmmm") ;%> <fix:if test="${user==null }"> 未登陆. <br> </fix:if> <fix:if test="${user!=null }"> welcome用户已经登录. <br> </fix:if>
ssss </body> |
<tag> <description>Outputs Hello, World</description> <name>if</name> <tag-class>cn.itcast.web.tag.example.IfTag</tag-class> <body-content>scriptless</body-content> <attribute> <name>test</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> |
JSP:自定义标签之<c:if>标签
最新推荐文章于 2023-11-26 10:30:55 发布