Spring Boot With Thymeleaf and HTML
Spring Boot With Thymeleaf and HTML
1. Project Setup:
2. Controller:
Example:
Java:
@Controller
public class HomeController {
@RequestMapping("/")
public String home(Model model) {
model.addAttribute("message", "Welcome to Spring Boot with
Thymeleaf!");
return "home"; // View name
}
}
3. Thymeleaf Templates:
Example (home.html):
HTML:
<!DOCTYPE html>
● Start the Spring Boot application using mvn spring-boot:run or your IDE's run feature.
● Access the application in a web browser (e.g., http://localhost:8080).
Key Points:
Additional Features: