Wednesday, September 8, 2010

Repeat HashMap using JSTL tags

Lets assume You have a HashMap like this:

Map map = new HashMap();
map.put("fruits", "Apples");
map.put("Vegetables", "Tomota");
map.put("Vehicles", "Hero Honda");
request.setAttribute("itemsMap", map);


We need the following code to repeat the HashMap Using JSTL tags

c:forEach var="item" items="${itemsMap}">

Key is : ${item.key} and value is: ${item.value}



/c:forEach>

Please note that "<" is missing before c:forEach tag

No comments:

Post a Comment