具有c:foreach jstl标签的二维arraylist [英] Two dimensional arraylist with c:foreach jstl tag

查看:80
本文介绍了具有c:foreach jstl标签的二维arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个混合的JSTL <c:forEach>中使用二维arraylist:

I'm using a two dimension arraylist in two imbricated JSTL <c:forEach>:

<select multiple size="30">
    <c:forEach var="uri" items="${defaultResult}" varStatus="iterator">
        <c:forEach var="cate" items="${defaultResult[iterator.index]}">
         <option value="${defaultResult[iterator.index][0]}"> ${cate}[1]</option>
        </c:forEach> 
    </c:forEach>
</select>

,但索引似乎无法正常工作,例如,${cate}[1]返回的值是所有维的所有值,后跟[1]

but the indexes seem not to be working, for example the values returned by ${cate}[1] are all the values of any dimension followed by [1]

如果您有解决我问题的想法,那将是有帮助的.

If you have any idea to solve my problem it would be helpful.

推荐答案

它需要放在表达式内部,而不是外部.

It needs to go inside the expression, not outside.

${cate[1]}


顺便问一下,为什么不访问第一个循环的var?

<c:forEach var="uri" items="${defaultResult}">
    <c:forEach var="cate" items="${uri}">
        <option value="${uri[0]}">${cate[1]}</option>
    </c:forEach> 
</c:forEach>

这篇关于具有c:foreach jstl标签的二维arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆