Skip to main content

Thymeleaf Fragments

Learn Thymeleaf Fragments (Spring MVC + Thymeleaf, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes Fragment : a named, reusable piece of a template (header, footer, form row) declared with th:fragment and pulled into pages, so markup is written once. Include a fragment with th:insert (keeps the host tag) or th:replace (replaces the host tag), using the syntax ~{file :: name} . Location : fragments usually live in templates/fragments/ , and the file name is given without .html .

More lessons in Spring MVC + Thymeleaf