-
Notifications
You must be signed in to change notification settings - Fork 2
Spring Expression Language
The Spring Expression Language (spel
) is a general purpose language suited for reading data
properties and performing simple operations using a simple syntax. See SpEL Syntax for
information on the language syntax.
When an expression is evaluated, it will be given a root object that serves as the object that the expression can make references to (for example, read the properties of). You must consult the documentation for the service making use of expressions to understand what the root object is, and what properties it exposes to the expression.
Variable names are only allowed to contain specific characters. When expressions are evaluated, any variables provided to the expression will encode unsupported characters as hexadecimal values. You must consult the documentation for the service making use of expressions to understand what variables are provided to the expression, if any.
The following sets of characters are allowed:
a - z
A - Z
0 - 9
_
$
The name may not start with a number. Any illegal character will be replaced by a hexadecimal encoding of the character's raw value, using lower case letters. For example:
-
Data+
becomesData2b
-
Data-
becomesData2d
There are online tools available (for example here) to help with encoding characters.
Imagine a root object that looks like the following, expressed as JSON:
{
"firstName" : "John",
"lastName" : "Doe",
"age" : 45,
"favorites" : {
"number" : 6,
"color" : "red"
},
"aliases" : [
"John",
"Jonny",
"Face"
]
}
Here are some sample expressions, and the result they yield:
Example | Result |
---|---|
age * favorite.number |
270 |
firstName + '"' + aliases[2] +'"' + lastName |
John "Face" Doe |