jstl中的if else

来源:互联网 发布:网吧网络组建方案 编辑:程序博客网 时间:2024/06/05 04:05

在jstl中没有像Java中的if() else{} 的语句,不过在jstl中提供了一个choose标签描述如下:

<c:choose>    <c:when test=''><!--相当于if-->       </c:when>    <c:when test=''><!--相当于else if-->       </c:when>    <c:when test=''><!--相当于else if-->       </c:when>    <c:otherwise><!--相当于else-->      </c:otherwise></c:choose>


<c:choose>、<c:when>和<c:otherwise>标签的使用必须符合以下语法规则:

<c:when>和<c:otherwise>不能单独使用,它们必须位于<c:choose>父标签中。

在<c:choose>标签中可以包含一个或多个<c:when>标签。

在<c:choose>标签中可以不包含<c:otherwise>标签。

在<c:choose>标签中如果同时包含<c:when>和<c:otherwise>标签,那么<c:otherwise>必须位于<c:when>标签之后。

0 0