Skip to content

Thymeleaf version 3 Spring configuration

To upgrade a project to Thymeleaf version 3 within a Spring environment, specific dependency properties must be updated in the project's configuration file.^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md]

Dependency Configuration

The upgrade requires setting the thymeleaf.version property to 3.0.11.RELEASE.^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md] Additionally, the [[Thymeleaf Layout Dialect]] version should be synchronized to 2.3.0 to ensure compatibility with the core engine update.^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md]

Maven Configuration

The following XML configuration snippet demonstrates the required properties:

<properties>
    <java.version>1.8</java.version>
    <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
</properties>

Syntax Features

Thymeleaf 3 supports a variety of expression syntaxes for different templating needs^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md]:

  • Variable Expressions (${...}): Used for Object-Graph Navigation Language (OGNL) expressions.
  • Selection Expressions (*{...}): Used to select a specific object, often used with forms (e.g., *{object.xxx}).
  • Internationalization (#{...}): Used for retrieving localized messages.
  • URL Expressions (@{...}): Used for specifying URLs.
  • Fragment Expressions (~{...}): Used for referencing reusable template fragments.

Additionally, attributes like th:id are designed to replace standard HTML attributes entirely^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md].

Sources

^[600-developer__java__spring__thymeleaf__spring-thymeleaf-01.md]