<c:set var="nameLookup" value="${names}" />
<c:forEach var="result" items="${results}">
<tr>
<td>${result.uglyDisplayName}</td>
<td>${result.phonenum}</td>
</tr>
</c:forEach>
This is an excerpt from a jsp I'm trying to edit.
Results is a List<Object>
being returned in the ModelAndView from the controller, of which each Object
has a getUglyDisplayName
and getPhonenum
. I'm not actually clear on how that's working. I guess the jsp is doing some getClass().getName()
or something behind the scenes? Any pointers on that process would be enlightening. Anyway, that part is working.
In the controller I've added another object to be returned in the ModelAndView. It's a HashMap that has nicer display names for which the ugly display names are the keys. So I want to replace that first td with something like this:
<td>${nameLookup.get(result.uglyDisplayName)}</td>
This doesn't work, obviously, or I wouldn't be posting here. I went ahead and set a var to the name I put the HashMap in the ModelAndView under (top line) but I'm not sure if that's the right way to get at that object.