springboot 整合 thymeleaf通过控制器返回页面404
1.通过控制器返回页面404
2.解决方案
网上查验了很多解决方案,但对我项目都没有作用。这里先总结一下网上说到的一些解决方案:
1)控制器不能添加注解@RestController,应使用@Controller,否则会返回字符。或者检查@RequestMapping的url是否正确。
2)pom文件添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
3)添加application.properties配置
#thymeleaf
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.mode=