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

https://stackoverflow.com/questions/5322632/spring-expression-language-spel-with-value-dollar-vs-hash-vs#answer-20133659


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.

https://docs.oracle.com/javaee/6/tutorial/doc/bnahr.html

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need