šæ What is Thymeleaf?
Thymeleaf is a template engine ā it helps you create dynamic HTML pages in a Spring Boot application.
Think of it like this:
Just like MS Word uses templates to generate documents, Thymeleaf helps generate web pages by filling in data automatically.
š How it works with Spring Boot?
- You create an HTML page with Thymeleaf tags (like
${name}
). - Spring Boot sends data from your Java code (Controller) to the HTML page.
- Thymeleaf replaces those tags with real data and shows the final page to the user.
š¦ Example
Controller (Java code):
Thymeleaf HTML (greeting.html):
š„ļø Output:
Hello, Aftab!
ā Why use Thymeleaf?
- Easy to learn
- Works well with Spring Boot
- Helps build UI with real-time data
- Supports loops, conditions, and formatting