Thymeleaf Expressions
Get introduced to the usage of Thymeleaf expressions.
We just introduced the Thymeleaf expressions (enclosed within th:*
tags). These can be classified into six categories:
- Variables
- Text
- Selected objects
- Links
- Literal substitutions
- Expression inlining
Variables
When a Thymeleaf template gets processed, the application will put variables in the context via the
controller. We can reference those variables in the templates via the ${…}
syntax. For example:
<div th:text="${username}"></div>
Suppose there is a String
in the Thymeleaf context with the name username
that has the value “John Doe.” The HTML will be rendered as: ...