Re: myMap.get(myKey) with JSTL?
Christine Mayer wrote:
This works:
<c:out value="${myKey}"/> Output: E.g. 4711
<c:out value="${myMap}"/> Output: The content of the entire object
This however does not work(empty output):
<c:out value="${myMap['4711']}"/>
<c:out value="${myMap[myKey]}"/>
<c:out value="${myMap.myKey}"/>
<c:out value="${myMap.'4711'}"/>
myMap contains a String key and a bean as value. The bean encapsulates
a list (that contains other beans again), that I later want to iterate
over. What I would like to achieve is something like:
<c:set value="${myMap[myKey]}" var="myBean"/>
Odd. According to
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnahv>
To refer to properties of a bean or an Enum instance, items of a
collection, or attributes of an implicit object,
you use the . or [] notation, which is similar to the notation used by ECMAScript.
....
In contrast, an item in a Map can be accessed using a string literal key; no coercion is required:
${customer.orders["socks"]}
.... and
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnain>
${departments[deptName]}
The value of the entry named deptName in the departments map.
--
Lew