Travis
Travis

Reputation: 11

accessing values in a map using c:out tag

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

Upvotes: 0

Views: 1917

Answers (2)

Travis
Travis

Reputation: 11

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.

Upvotes: 1

Asaph
Asaph

Reputation: 162801

You left out the ${}. Try this:

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

Upvotes: 3

Related Questions