我想在 JSTL 的 foreach 中插入“继续”。请让我知道是否有办法实现这一目标。
<c:forEach
var="List"
items="${requestScope.DetailList}"
varStatus="counter"
begin="0">
<c:if test="${List.someType == 'aaa' || 'AAA'}">
<<<continue>>>
</c:if>
我想在 if 条件中插入“继续”。
最佳答案
没有这样的事情。只需对您实际想要显示的内容进行逆操作即可。所以不要这样做
<c:forEach items="${requestScope.DetailList}" var="list">
<c:if test="${list.someType eq 'aaa' or list.someType eq 'AAA'}">
<<<continue>>>
</c:if>
<p>someType is not aaa or AAA</p>
</c:forEach>
而是做
<c:forEach items="${requestScope.DetailList}" var="list">
<c:if test="${not (list.someType eq 'aaa' or list.someType eq 'AAA')}">
<p>someType is not aaa or AAA</p>
</c:if>
</c:forEach>
或者
<c:forEach items="${requestScope.DetailList}" var="list">
<c:if test="${list.someType ne 'aaa' and list.someType ne 'AAA'}">
<p>someType is not aaa or AAA</p>
</c:if>
</c:forEach>
请注意,我还修复了您代码中的 EL 语法错误。
关于jsp - JSTL 继续,在 foreach 内中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7578420/