tags:

views:

63

answers:

2

hi there, trying to access a value from a map in a c:out tag but the following doesn't appear to be displaying any value. Here's the code:

<c:out value=" letterForm.criteria.map['letterForm.criteria.type']" />

anyone have any ideas how to get the value from a map other than using the following code as it seems a bit inefficient as we have a map and know the key value.

<c:forEach var="exCovValue" items="${letterForm.criteria.map}">
     <c:if test="${exCovValue.key == letterForm.criteria.type}">
         <c:set var="extraCoverValue" value="${exCovValue.value}" />
     </c:if>
</c:forEach>

Thanks

+3  A: 

You left out the ${}. Try this:

<c:out value="${letterForm.criteria.map['letterForm.criteria.type']}" />
Asaph
+1  A: 

This worked:

<c:out value="${letterForm.criteria.map[letterForm.criteria.type]}" />

was trying it like this:

<c:out value="${letterForm.criteria.map['letterForm.criteria.type']}" />

but removing the quotes (') worked.

Travis
oops, forgot that in the example!cheers for the help
Travis
The `letterForm.criteria.type` is a variable which has a value which apparently is one of the map keys. The `'letterForm.criteria.type'` is a plain vanilla string which apparently isn't one of the map keys. Do you now understand why it behaves that way?
BalusC