Reputation: 49
I have a hashmap as HashMap<String, Object>
How can I get key
and some Bean variable
from the object
value in the JSP form?
HashMap<String, Object> labelList = populateFieldLabels(users);
model.addAttribute("labelList", labelList);
I have already tried this:
<c:out value="${labelList.key}"></c:out>
Upvotes: 0
Views: 2827
Reputation: 3507
You can iterate maps like this
<c:forEach items="${labelList}" var="label">
<c:out value="${label.key}"></c:out>
</c:forEach>
Upvotes: 2
Reputation: 13556
If you need to iterate through map,
<c:forEach items="${labelList}" var="item">
<c:out value="${item.key}"></c:out>
</c:forEach>
Upvotes: 1