I have a map like this,
Map<Integer,ArrayList<Object>> myMap = new LinkedHashMap<Integer,ArrayList<Object>>();
Now I have to iterate this Map and then the ArrayList inside the map. How can I do this using JSTL?
I have a map like this,
Map<Integer,ArrayList<Object>> myMap = new LinkedHashMap<Integer,ArrayList<Object>>();
Now I have to iterate this Map and then the ArrayList inside the map. How can I do this using JSTL?
you haven't closed c tag.try out this
You can also loop round just the map.value its self if you know the key
Did you try something like this?
You can use JSTL
<c:forEach>
tag to iterate over arrays, collections and maps.In case of arrays and collections, every iteration the
var
will give you just the currently iterated item right away.In case of maps, every iteration the
var
will give you aMap.Entry
object which in turn hasgetKey()
andgetValue()
methods.In your particular case, the
${entry.value}
is actually aList
, thus you need to iterate over it as well:The
varStatus
is there just for convenience ;)To understand better what's all going on here, here's a plain Java translation:
See also: