我想做如下的事情:
<c:choose>
<c:when test="${empty example1}">
</c:when>
<c:otherwise>
<c:when test="${empty example2}">
</c:when>
<c:otherwise>
</c:otherwise>
</c:otherwise>
</c:choose>
这可能吗?尝试运行时抛出异常。
谢谢。
最佳答案
你需要更像这样:
<c:choose>
<c:when test="${empty example1}">
<!-- do stuff -->
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${empty example2}">
<!-- do different stuff -->
</c:when>
<c:otherwise>
<!-- do default stuff -->
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
这里显示的冗长是一个很好的例子,说明为什么 XML 是一种用于实现多级条件语句的糟糕语言。
关于java - 我如何在 Java JSP 的 JSTL 中执行 "nested if"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5447157/