Javatpoint Logo
Javatpoint Logo

Spring Boot Thymeleaf View


Thymeleaf

It is a server side Java template engine for web application. It's main goal is to bring elegant natural templates to your web application.

It can be integrate with Spring Framework and ideal for HTML5 Java web applications.

In the following example, we are using Thymeleaf as our HTML template and rendering it from controller.

In order to use Thymeleaf we must add it into our pom.xml file like:

after that mentioning it in our template that we are using this library. Like:

Our project has the following directly structure.

Spring Boot thymeleaf view 1

In our project, we have following files.

// index.html

// user-data.html

// User.java

// pom.xml

// HomeController.java

// SpringBootExampleApplication.java

Output:

After running the application. It produce the following output.

Index Page

Spring Boot thymeleaf view 2

Entering details

Spring Boot thymeleaf view 3

After submitting form

Spring Boot thymeleaf view 4
Next TopicSpring Boot JPA




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials