springboot报错,Circular view path [index]: would dispatch back to the current handler URL […
经检查,跳转代码没有问题,甚至逻辑都没写,但始终报错,多方查找,finally,我发现了这个:
注:版本改一改,原因是springboot默认支持2.x版本,因此需要手动修改
<properties>
<java.version>11</java.version>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
在application.properties中可以自己配置参数
spring.thymeleaf.prefix=classpath:/templates/ 设置thymeleaf路径默认为src/main/resources/templates
spring.thymeleaf.suffix=.html 设置thymeleaf模板后缀
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false 是否开启缓存默认为true
spring.thymeleaf.mode=LEGACYHTML5 设置thymeleaf严格校验
spring.thymeleaf.encoding=UTF-8 设置编码
顺便记录一下,
@RestController:返回的就是return后的内容,和@Controller不一样哦
另外,如果需要查询对应的版本,在pom.xml中,按住ctrl点击
<artifactId>spring-boot-starter-parent</artifactId>
<artifactId>spring-boot-dependencies</artifactId>
查看对应的thymeleaf版本

本文详细介绍了在SpringBoot应用中遇到循环视图路径错误的解决方案,重点讲解了如何通过修改`thymeleaf`版本和配置文件来避免这个问题,包括设置前缀、后缀、编码等关键参数。
1427

被折叠的 条评论
为什么被折叠?



