使用springBoot报错Circular view path [success]: would dispatch back to the current handler URL 解决方法
使用springboot在整合使用thymeleaf模板时报错,出错原因应该是使用thymeleaf 模板版本跟springBoot不匹配第一种快速解决的方法是直接将@controller改为@RestController返回页面用@Controller,返回数据用@RestController第二种方式是更改thymeleaf版本使其与springBoot版本匹配就行。起初pom.xml的配置是
·
使用springboot在整合使用thymeleaf模板时报错,出错原因应该是使用thymeleaf 模板版本跟springBoot不匹配。
第一种快速解决的方法
直接将@controller或者后面加一个@ResponseBody,其作用是将返回的数据以字符串的方式直接写给浏览器,而不是跳转到某个页面。
或者直接将@controller改为@RestController,这是spring新出的注解,相当于将@controller和@ResponseBody整合到一起。
第二种方式
更改thymeleaf版本使其与springBoot版本匹配就行。
起初pom.xml的配置是这样
<!--Thymeleaf-->
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-java8time -->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
在后面增加下面这段代码再一运行就能成功了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)