i am passing a TreeMap to a JSP page. The map contains as keys the days of the current or the next month. The passed data has to be rendered in the JSP page. Therefore i need a way to access the .containsKey()
or .containsValue()
or the .get()
method from the map. I tried these methods but i always get an exception.
When i'm using the .get(1)
or .get("1")
method i eclipse shows me a ClassCastException
java.lang.Integer cannot be cast to java.lang.Long
Any ideas how to solve my problem?
Edit: The Code:
public TreeMap<String, String> getCalendarEntries(
boolean showNextMonth) throws Exception{
TreeMap<String, String> treeMap = new TreeMap<String, String>();
// doing some stuff...
treeMap.put("2", "someValue");
// ..
return treeMap;
}
The controller
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String home(Locale locale, Model model) throws Exception {
// do stuff..
TreeMap<String, String> treeMap = getCalendarEntries(true);
model.addAttribute("treeMap", treeMap);
return "home"
}
The JSP Page
<c:forEach var="calendarEntry" items="${calendarEntries }">
${calendarEntry.getKey()}-${calendarEntry.getValue()}
// Returns the key/value mapping
</c:forEach>
${calendarEntries.get("2")}
// returns nothing.