Use <c:forEach> with HashMap [duplicate] Use <c:forEach> with HashMap [duplicate] java java

Use <c:forEach> with HashMap [duplicate]


Yes, this is perfectly acceptable.

When you use <c:forEach> to iterate over a Map, each item in the iteration is an instance of Map.Entry. So given your example:

<c:forEach var="type" items="${types}">   Key is ${type.key}   Value is ${type.value}</c:forEach>


It works, you'll have type.key and type.value to play with in the loop.