JSTL forEach索引问题

时间:2014-09-29 16:20:33

标签: jsp jstl

我有一个嵌套的jstl forEach循环,由于某种原因,只要代码到达最内层循环,索引就会重新启动。因此,当我尝试将索引用作id的一部分时,生成的按钮具有重复的id。不应该继续索引还是我不正确地看待这个?这是一段代码片段。

    <c:forEach items="${groups}" var="group" varStatus="groupstatus">

        <c:forEach items="${items}" var="item" varStatus="itemstatus">

            <c:forEach items="${form.properties}" var="property" varStatus="status">

                   <button id="btn-${status-index}">title here</button>

            </c:forEach>

        </c:forEach>

    </c:forEach>

1 个答案:

答案 0 :(得分:0)

status将成为内循环的本地。它将针对${items}的每次迭代重置。

如果您正在寻找该级别的全球唯一ID,则可能需要btn-${groupstatus.index}-${itemstatus.index}-${status.index}之类的内容。

相关问题