I think the id beans attribute is not a wrapper object ( Integer id;). See the Map document page .
Text from JavaDoc
: , . , , . , , . , , : equals hashCode .
Item.java
package com.me;
public class Item {
private Integer id;
private String description;
public Item() {
}
public Item(Integer id, String description) {
this.id = id;
this.description = description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
JSP
<%
HashMap<Integer, String> myMap = new HashMap<Integer, String>();
myMap.put(new Integer(1), "One");
myMap.put(new Integer(2), "Two");
myMap.put(new Integer(3), "Three");
request.setAttribute("myMap", myMap);
List<com.me.Item> list=new ArrayList<com.me.Item>();
list.add(new com.me.Item(1,"A - Desc"));
list.add(new com.me.Item(2,"B - Desc"));
list.add(new com.me.Item(3,"C - Desc"));
request.setAttribute("list", list);
%>
<c:forEach items="${list}" var="item" varStatus="status">
<c:out value="${item.description}"/>
<c:out value="${myMap[item.id]}"/>
</c:forEach>