SPRING CONCEPTS

Thymeleaf

Spring Concepts / Thymeleaf

Thymeleaf is a server-side template engine used here to render HTML.

Understand the idea

th:each repeats content; th:text inserts escaped text; th:if conditionally shows markup; th:object selects a form object; th:field binds a property; th:errors displays validation feedback. URL expressions use @{...}.

A concrete example

<td th:text="${todo.title}"></td>
<input th:field="*{title}">

In the application

The MVC controller supplies data, Thymeleaf renders the task table and form, and the browser receives ordinary HTML.

Prefer escaped th:text for user-provided titles. Do not render arbitrary user text as unescaped HTML.

See it in a working stage

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly