This syntax ought indeed to work. I understand that you didn't get any value by the given object as key although you're confident that the desired object is in there? In that case, the class as represented behind ${anObject}
in your code must have the equals()
(and hashCode()
) methods properly implemented. The Map#get()
namely tests the key by equals()
method. See also the javadoc:
Returns the value to which the specified key is mapped, or null
if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k))
, then this method returns v; otherwise it returns null
. (There can be at most one such mapping.)
In other words, if the equals()
of your ${anObject}
returns true
for the map key, then the associated map value will be returned, otherwise null
will be returned and EL will then print nothing.
That it works for String
is simply because that class has the equals()
already properly implemented.
See also: