Spring expression Language (Spel): is a powerful expression language that supports run-time querying and manipulating object graphs .
Syntax similar to El:spel using #{...} as delimiters, all characters in the large frame number will be considered spel
Spel provides the convenience for dynamic assignment of bean properties
The Spel can be implemented by:
-
- To reference a bean by its ID
- Calling methods and referencing properties in an object
- Evaluate the value of an expression
- Matching of regular expressions
Representation of a literal
integer : <property name= "Count" value= "#{5}"/>
decimals : <property name= "Frequency" value= "#{89.7}"/>
scientific notation : <property name= "Capacity" value= "#{1e4}"/>
string can use single or double quotation marks as the bounding symbol of a string: <property name= "name" value= "#{' Chuck '}"/> or <property name= ' name ' Value= ' #{"Chuck"} '/>
Boolean: <property name= "Enabled" Value= "#{false}"/>
Note: It is not very significant to use Spel if it is only a literal value. You can assign values directly in value.
Reference beans, properties, and methods refer to other objects:
Referencing properties of other objects (Spel exclusive)
Call other methods and also chain-operated (Spel exclusive)
Calling a static method or static property
By calling a static method of a class by T (), it returns a class Object and then invokes the appropriate method or property:
Spel supported arithmetic notation arithmetic operators: +,-, *,/,%, ^:
The plus sign can also be used as a string connection: comparison operator: <,;, = =, <=, >=, lt, GT, eq, le, ge
Logical operation symbols: and, or, not, |
If-else operator:?: (Ternary),?: (Elvis)
Variants of the If-else
Regular expression: Matches
Spring4-2-bean Configuring the -6-spring expression language Spel