javaWeb带父标签的自定义标签(2)
要实现如下代码 <c:choose> <c:when test="${param.age>24}">大学毕业</c:when> <c:when test="${param.age>20}">高中毕业</c:when> <c:otherwise>高中以下</c:otherwise> </c:choose> 1>开发3个标签:choose,when,otherwise 2>其中when标签有一个boolean 类型的属性:test 3>choose 是when和otherwise的父标签,when在otherwise之前使用 4> 在父标签 choose中定义一个“全局”的boolean 类型的flag:用于判断子标签在满足条件的情况下是否执行。 1> 若when 的test为true,且when的父标签的flag也为ture 则执行when的标签体(正常输出标签体的内容),同时把flag设置为false 2> 若when 的test为true,且when的父标签的flag也为false,则不执行标签体。 3> 若flag为ture,otherwise执行标签体。