Java Reference
In-Depth Information
Table 2-1. Expression Language Features
Literal expression
The simplest thing you can do in the
expression language; essentially
the same as if you were writing Java
code. The language supports String
literals as well as all sorts of
'Hello Spring Enterprise Recipes'
Boolean and
relational operator
The expression language provides
the ability to evaluate conditionals
using standard idioms from Java.
T(java.lang.Math).random() > .5
Standard expression
You can iterate and return the
properties on beans in the same
way you might with Unified EL,
separating each dereferenced
property with a period and using
JavaBean-style naming conventions.
In the example to the right, the
expression would be equivalent to
getCat().getMate().getName() .
T() tells the expression language to
act on the type of the class, not an
instance. In the examples on the right,
the first would yield the Class instance
for java.lang.Math -equivalent to
calling java.lang.Math.class .
The second example calls a static
method on a given type. Thus,
T(java.lang.Math).random() is
equivalent to calling
java.lang.Math.random() .
Class expression
Accessing arrays,
lists, maps
You can index lists, arrays, and maps
using brackets and the key—which
for arrays or lists is the index
number, and for maps is an object.
In the examples, you see a
java.util.List with 4 chars being
indexed at index 1, which returns 'b'.
The second example demonstrates
accessing a map by the index 'OR',
yielding the value associated with
that key.
Search WWH ::

Custom Search