<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>
4条答案
按热度按时间gpfsuwkq1#
没有这样的事情。只要对你 * 实际 * 想要显示的内容做相反的操作就可以了。所以不要
而是
或
请注意,我还修复了代码中的EL语法错误。
bxjv4tth2#
我在可执行代码的末尾和循环内部使用Set解决了这个问题
然后我使用该变量在下一次迭代中跳过代码的执行,方法是使用
您可以随时将其设回true ...
有关此标签的更多信息,请访问:JSTL Core Tag
好好享受吧!
3hvapo4f3#
或者可以用EL***选择***语句
dy1byipe4#
我喜欢这样的想法:在foreach上设置变量,并将其设置为循环的末尾,以便在构造一个开始和end for循环时使用c:set退出。
https://www.codesenior.com/en/tutorial/How-To-Break-Foreach-Loop-in-JSP