Spring Expression Language (SpEL) with @Value: dollar vs. hash ($ vs. #) Spring Expression Language (SpEL) with @Value: dollar vs. hash ($ vs. #) spring spring

Spring Expression Language (SpEL) with @Value: dollar vs. hash ($ vs. #)


${...} is the property placeholder syntax. It can only be used to dereference properties.

#{...} is SpEL syntax, which is far more capable and complex. It can also handle property placeholders, and a lot more besides.

Both are valid, and neither is deprecated.


${expr} --> Immediate Evaluation

#{expr} --> Deferred Evaluation

Immediate evaluation means that the expression is evaluated and the result returned as soon as the page is first rendered. Deferred evaluation means that the technology using the expression language can use its own machinery to evaluate the expression sometime later during the page’s lifecycle, whenever it is appropriate to do so.

Complete reference here

There is no JSP EL, JSP uses SpEL. SpEL fits to technology that is using it.


Try reading this article, which suggests

"If the hash is used, your code is recomputed every time that element is included in a partial refresh (i.e. each time it is rendered). If you use a dollar, your code is only computed when the page is initially loaded. But this has been extended beyond just EL, to SSJS too. After the hash or dollar, the curly braces denote the start and end of your language. This will be important when we come to combining languages later."