具体的报错信息:
在网上找的解决方法大体上有这么几种:
- 把@Controller改成@RestController
- 有可能是thymeleaf依赖导入异常,或者没导入thymeleaf依赖,可以尝试到pom.xml中导入thymeleaf依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
如果改完发现还是报500错误,可以去application.properties文件中将thymeleaf的缓存关闭
spring.thymeleaf.cache=false
- @RequestMapping(“hello”)中的路径与映射方法返回的视图名冲突了,不能写一样的
就是这两个地方名字不能一样。
我是使用第三个方法解决的问题。