How do you display a variable’s value in Thymeleaf?
A)
[[${variable}]]
B)
{{variable}}
C)
${variable}
D)
$[variable]
Answer:
A)
[[${variable}]]
Explanation:
In Thymeleaf, the double square brackets [[${variable}]]
are used to display the value of a variable within an HTML element. This syntax ensures that the value is properly escaped and rendered as text in the browser.
For example:
<p>Hello, [[${name}]]!</p>
In this example, the value of the name
variable is displayed inside a paragraph element.