如何在 JSTL 中编写多个具有 begin、end 和 var 属性的 For Each 语句?

How to write multiple For Each statement in JSTL, with begin, end and var attributes?

如何在 JSP 中使用具有 end、var 和 begin 属性的多个 JSTL for-each 循环?

我 运行 遇到了一个问题,我有两个 for-each 语句。第一条语句中的内容正在显示;但是对于每个循环的第二个,它没有显示任何内容。

<c:forEach end="${economy.flagBank}" var="loopIndex" begin="1">
 1
</c:forEach>
<c:forEach end="${economy.flagTank}" var="loopIndex" begin="1">
  2
</c:forEach>
 //   Both flagBank and flagTank have 1.

 Output: 1

以上说法有没有错误?我需要在页面上写大约 10 个 for-each。

唯一可能的解释是,${economy.flagTank} 不是您写的 1。

                <c:forEach end="1" var="loopIndex" begin="1">
                    1
                </c:forEach>
                <c:forEach end="1" var="loopIndex" begin="1">
                    2
                </c:forEach>

产生 1 2 的输出,所以你必须有类似 ${economy.flagTank} < 1