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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use JSTL
<c:forEach>tag to iterate over arrays, collections and maps.In case of arrays and collections, every iteration the
varwill give you just the currently iterated item right away.In case of maps, every iteration the
varwill give you aMap.Entryobject 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
varStatusis there just for convenience 😉To understand better what’s all going on here, here’s a plain Java translation:
See also: