Spring Certified Professional 2023 · Free Practice Question Easy
Question 1
What symbol is used in @Value expressions in Spring? (select 2)
-
A
$
-
B
%
-
C
#
-
D
^
Reveal correct answers
Correct answers: A, C
Explanation
The symbol "$" is commonly used in @Value expressions to refer to the value of a property or environment variable.
The symbol "#{...}" is also used in @Value expressions to evaluate SpEL (Spring Expression Language) expressions and dynamically compute the value.
Spring Academy-related video: https://spring.academy/courses/spring-framework-essentials/lessons/spring-essentials-more-java-config-spel
See also:
${expr} --> Immediate Evaluation
#{expr} --> Deferred Evaluation
Javadoc:
The EL supports both immediate and deferred evaluation of expressions. 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.
Those expressions that are evaluated immediately use the ${} syntax. Expressions whose evaluation is deferred using the #{} syntax.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
