posted 17 years ago
This question wants to stress about the difference between accessing a Map and a List in EL.
"a" is variable which does not exist. When using a Map, ${myBean["params"].a}, won't because it will search for the key "a" in the map "params", calling containsKey() and get().
However, you can do this with a List only using integers.
Here are the details from the spec:
- expr-a.identifier-b is equivalent to expr-a["identifier-b"];
- Evaluate expr-a into value-a
- Evaluate expr-b into value-b
- If value-a is a Map, List, or array:
- If value-a is a Map:
If !value-a.containsKey(value-b) then return null.
Otherwise, return value-a.get(value-b)
- If value-a is a List or array:
- Coerce value-b to int (using coercion rules)
If coercion couldn't be performed: error
"a" is not an int, so error is produced.