开发者

accessing values in a map using c:out tag

开发者 https://www.devze.com 2022-12-14 05:31 出处:网络
trying to access a value from a map in a c:out tag but the following doesn\'t a开发者_开发知识库ppear to be displaying any value. Here\'s the code:

trying to access a value from a map in a c:out tag but the following doesn't a开发者_开发知识库ppear 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


You left out the ${}. Try this:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消