1、引入thymeleaf依赖
org.springframework.boot spring-boot-starter-thymeleaf
2、在application.yml进行thymeleaf配置
# 配置页面地址spring: thymeleaf: prefix: classpath:/templates/
3、编写Controller
// 服务启动自动跳转首页@RequestMapping(value = {"/","index"})public String index(){ return "index";}
文件结构:
访问localhost:8080 或者 localhost:8080/index