spring Spring Expression Language (SpEL) Syntax Reference

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

You can use @Value("#{expression}") to inject value at runtime, in which the expression is a SpEL expression.

Literal expressions

Supported types include strings, dates, numeric values (int, real, and hex), boolean and null.

"#{'Hello World'}"  //strings
"#{3.1415926}"      //numeric values (double)
"#{true}"           //boolean
"#{null}"           //null

Inline list

"#{1,2,3,4}"              //list of number
"#{{'a','b'},{'x','y'}}"  //list of list

Inline Maps

"#{name:'Nikola',dob:'10-July-1856'}" 
"#{name:{first:'Nikola',last:'Tesla'},dob:{day:10,month:'July',year:1856}}" //map of maps

Invoking Methods

"#{'abc'.length()}"      //evaluates to 3
"#{f('hello')}"   //f is a method in the class to which this expression belongs, it has a string parameter


Got any spring Question?