pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
application.yml
spring:
thymeleaf:
cache: false
encoding: UTF-8
mode: HTML5
prefix: classpath:/templates/
suffix: .html
content-type: text/html
@Controller
public class IndexController {
@GetMapping("/index")
public String home() {
return "index";
}
}
templates/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello, Thymeleaf!</title>
</head>
<body>
<h1>Welcome!</h1>
</body>
</html>