JSTL继续,破解里面的foreach [英] JSTL continue, break inside foreach
本文介绍了JSTL继续,破解里面的foreach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< c:forEach
var =List
items =$ {requestScope.DetailList}
varStatus =counter
begin =0>
<<<<继续>>>
< / c:if>
我想在if条件中插入continue。
解决方案
没有这样的事情。只要对你想要显示的内容进行反转即可。所以不要做
pre code>< c:forEach items =$ {requestScope.DetailList}var =list> ;
< c:if test =$ {list.someType eq'aaa'or list.someType eq'AAA'}>
<<<<继续>>>
< / c:if>
< p> someType不是aaa或AAA< / p>
< / c:forEach>
而不是
< c:forEach items =$ {requestScope.DetailList}var =list>
< p> someType不是aaa或AAA< / p>
< / c:if>
< / c:forEach>
或
< c:forEach items =$ {requestScope.DetailList}var =list>
< p> someType不是aaa或AAA< / p>
< / c:if>
< / c:forEach>
请注意,我在代码中也修正了一个EL语法错误。
I want to insert "continue" inside foreach in JSTL. Please let me know if there is a way to achieve this.
<c:forEach
var="List"
items="${requestScope.DetailList}"
varStatus="counter"
begin="0">
<c:if test="${List.someType == 'aaa' || 'AAA'}">
<<<continue>>>
</c:if>
I want to insert the "continue" inside the if condition.
解决方案
There's no such thing. Just do the inverse for the content you actually want to display. So don't do
<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>
but rather do
<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>
or
<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>
Please note that I fixed an EL syntax error in your code as well.
这篇关于JSTL继续,破解里面的foreach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文