Thymeleaf Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A single-page, colour-coded summary of the Thymeleaf essentials, written against Thymeleaf 3.1.5, Spring Boot 4.1.1
(Spring Framework 7.0.9), Layout Dialect 4.0.1, htmx 2.0 and htmx-spring-boot 5.2.0 (versions verified 2026-10-07) — dependencies, template locations, template modes and the spring.thymeleaf.* properties, the five expression types
and the basic objects, literals, operators and preprocessing, one line per utility object, the th:* attributes by
purpose with their precedence order, iteration status and truthiness, fragments, th:remove values and the Layout
Dialect, comments, blocks and inlining, Spring forms and #fields, internationalization, conversion and links,
Spring Security, fragment rendering and htmx, reactive rendering, testing, the dialect and processor types, a
template-security strip, and a strip of what changed since older tutorials — handy for quick memorization or as a
downloadable PDF desk reference.
For the full explanation, every option, and additional examples, see the dedicated pages:
Start here — Thymeleaf.
Foundations — Introduction & Architecture, Getting Started, Standalone Engine & Configuration, and Spring Boot Auto-configuration & Properties.
Core template language — Standard Expression Syntax, Literals, Operators & Preprocessing, Expression Utility Objects, Text & Attribute Setting, Iteration & Conditionals, Local Variables, Attribute Precedence, Comments & Blocks, Link URLs, Inlining, Textual Template Modes, and Natural Templates & Decoupled Logic.
Fragments and layouts — Fragments, Layouts & the Layout Dialect, and Reusable UI Components.
Spring MVC — Spring MVC Integration, Forms & Data Binding, Validation & Error Messages, Conversion & Formatting, Internationalization, Displaying Data, Pagination & Sorting, and Error Handling & Flash Messages.
Security — Spring Security Integration and Template Security & XSS.
Dynamic and interactive pages — Fragment Rendering & AJAX, htmx Fundamentals, htmx with Spring Boot, htmx Patterns, Alpine.js & Web Components, Server-Sent Events & WebSockets, and Reactive Rendering with WebFlux.
Assets and other outputs — Styling & Front-end Assets and Emails & Text Templates.
Quality, extension and operations — Testing, Extending Thymeleaf, Performance & Production, Tooling & IDE Support, and What’s Changed & Migration.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in the section bibliography.