0

我创建了一个条件标记,如果文件不存在则返回 false,如果文件存在则返回 true,并且函数将文件的内容设置为 var。看:

<hc:portalFile file="css/style.css" var="css" >
  <style type="text/css">
    ${css}
  </style>
</hc:portalFile>

现在我想在文件不存在时打印其他内容。所以当condition类中的函数返回false时。我是否需要创建类似的东西<c:choose><c:when></c:when><c:otherwise></c:otherwise></c:choose>或者我在这里完全错过了一些东西。

4

1 回答 1

0

你是对的,如果你有多个条件,比如 if else 你可以使用 jstl choose , when 和 else 标签:

    <c:choose>
        <c:when test="${condition1}">
            <!--Display what you want for condition1-->
        </c:when>
        <c:when test="${condition2}">
            <!--Display what you want for condition1-->
        </c:when>
        <c:otherwise>
            <!--Display what you want if none of the conditions are met-->
        </c:otherwise>
    </c:choose>

这里只显示一个条件结果,即,1)如果条件1满足,则跳过条件2,否则。2)如果条件1失败,条件2通过显示它并否则跳过。3)如果条件1和条件2被关闭,否则显示。

于 2014-04-24T14:05:19.607 回答