使用SpringBoot+Thyemleaf 遇到的问题

91 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

1. 使用Thyemleaf 模板时Controller 层要使用@Controller注解,使用RestController注解不会返回html页面

2. 要在application.properties配置文件里面添加Thyemleaf 配置

#返回页面的路径
spring.thymeleaf.prefix=classpath:/templates/
#文件后缀
spring.thymeleaf.suffix=.html
#模式
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.servlet.content-type=text/html
#编码格式
spring.thymeleaf.encoding=utf-8
#不需要缓存
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**