如何遍历jstl中的列表列表? [英] How to iterate over a list of lists in jstl?
本文介绍了如何遍历jstl中的列表列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的列表格式如下:
List<List<Obj>> l3 = new ArrayList<List<Obj>>();
Obj包含一个名为getVal的方法.
Obj contains a method called getVal.
如何为每个Obj输出getVal的值?
How can I output the value of getVal for each Obj ?
我可以使用:
<c:forEach var="mylist" items="${mylist}">
<c:out value="${mylist.val}"></c:out>
</c:forEach>
但是如何获取列表列表中包含的值?
But how do I get the values contained in a list of lists ?
推荐答案
就像您在Java中那样-带有嵌套循环:
Just like you would do it in Java - with nested loops:
<c:forEach var="innerList" items="${mylist}">
<c:forEach var="obj" items="${innerList}">
<c:out value="${obj.val}"></c:out>
</c:forEach>
</c:forEach>
这篇关于如何遍历jstl中的列表列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文