Java Reference
In-Depth Information
Method invocation
Methods may be invoked in
instances just as you would in Java.
This is a marked improvement over
the basic JSF or JSP expression
'Hello, World'.toLowerCase()
Relational operators
You can compare or equate values,
and the returned value will be a
23 == person.age
'fala' < 'fido'
Calling constructor
You can create objects and invoke
their constructors. Here you create
simple String and Cat objects.
new String('Hello Spring Enterprise
Recipes, again!')
new Cat('Felix')
Ternary operator
Ternary expressions work as you'd
expect, yielding the value in the
true case.
T(java.lang.Math).random() > .5 ?
'She loves me' : 'She loves me not'
The SpEL lets you set and evaluate
variables. The variables can be
installed by the context of the
expression parser, and there are
some implicit variables, such as
#this , which always refer to the root
object of the context.
Collection projection
A very powerful feature inside of
SpEL is the capability to perform
very sophisticated manipulations of
maps and collections. Here, you
create a projection for the list cats .
In this example, the returned value is
a collection of as many elements
being iterated that has the value for
the name property on each cat in the
collection. In this case, cats is a
collection of Cat objects. The
returned value is a collection of
String objects.
Search WWH ::

Custom Search