Introduction to Spring Expression Language
by, 11-16-2011 at 04:42 PM (2059 Views)
Up until now, in the tips Iíve shown, all the constructor arguments and bean properties have been statically wired in the Spring configuration XML. What this means is that any definition you make has to be provided during development. This also applies to other beans which need to be defined statically in the Spring configuration.
In Spring 3, the Spring Expression Language (SpEL) was introduced as a powerful and concise means of dynamically wiring values in constructor arguments or bean properties that are evaluated at runtime. With SpEL, it is now possible to have much more flexible bean wiring than it is possible to get using Springís traditional wiring style.
- SpEL has a great deal of functionality, including
- The ability to reference beans by their ID
- Invoking methods and accessing properties on objects
- Mathematical, relational, and logical operations on values
- Regular expression matching
- Collection manipulation
The means of writing a SpEL expression involves piecing together the various elements of the SpEL syntax. One of the best parts of this new language is that SpEL expressions are often composed of simpler expressions. In our next tip we will look at the basics of SpELs expression.