Spring Boot, a popular Java-based framework, simplifies the process of creating stand-alone, production-grade Java applications. When it comes to rendering views in Spring Boot, Thymeleaf is a popular templating engine. It's capable of creating clean and semantic HTML5 templates. Let's explore an example of using Thymeleaf in a Spring Boot application.

Before we dive into the example, ensure you have a running Spring Boot project. If you haven't, you can create one using start.spring.io, including 'Web' and 'Thymeleaf' as dependencies.

Setting Up Thymeleaf ViewResolver
Once you have your project set up, configure Thymeleaf as your default view resolver. In your application.properties file, add the following lines:

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
Creating a Simple Thymeleaf Template

Create a new file named index.html in the src/main/resources/templates/ directory. Add the following code:
```html
Welcome to Spring Boot Thymeleaf Example!
This is a fallback message.

```
Populating Data from Controller
Now, let's send some data from our Spring Boot controller to populate this template. Create a new controller class named IndexController:
```java @Controller public class IndexController { @GetMapping("/") public String index(Model model) { model.addAttribute("greeting", "Hello, Thymeleaf!"); return "index"; } } ```
The index method adds a new attribute named greeting with the value "Hello, Thymeleaf!". The return statement corresponds to the template name.

Displaying List Data with Thymeleaf
Let's display a list of items in an unordered list using Thymeleaf. Add the following code to your index.html file:









```html
```
Next, update your IndexController to pass a list of items to the view:
```java @GetMapping("/") public String index(Model model) { model.addAttribute("greeting", "Hello, Thymeleaf!"); model.addAttribute("items", Arrays.asList("Item 1", "Item 2", "Item 3")); return "index"; } ```
Navigating to the Template
Finally, to navigate to our Thymeleaf template, run your Spring Boot application and visit localhost:8080. You should see a welcoming message and a list of items displayed on the page.
That's it! You've successfully created a Spring Boot application with Thymeleaf templating. Dive deeper into Thymeleaf's features to create more dynamic and engaging web pages. Happy coding!