APITROVE BLOG

A tutorial of thymeleaf with spring boot

This is a brief tutorial which provides notes for some thymeleaf commands.

to add stylesheet(or any other static file from directory)

<link rel="stylesheet" type="text/css"  th:src="@{/css/style.build.tailwind.css}">

to add some html fragment:

<div th:include="~{template_path::function_in_template}"></div>

where the fragment is dfined as:

<div th:fragment="copy()"></div>

to add custom template data along with some string literal(fixed), use following syntax(example with th:value and index = 1):

<p th:value="|the index is ${index}|"></p> -> <p>the index is 1</p>