springboot+thymeleaf项目,在获取前端传来的json数据时报错
Error resolving template “xxx”, template might not exist or might not be accessible by any of the configured Template Resolvers
可以获取到数据,但是会报错
解决办法:在获取数据的方法上添加@ResponseBody注解
个人理解:这个方法是用来区分方法的返回值字符串 和 视图解析器解析的页面名字字符串 的冲突的,@RequestMapping后,返回值通常解析为跳转路径,如果不添加这个注解,会在templates里面寻找相应的页面,添加了这个注解就表明该方法的返回值直接写入到 HTTP Response Body 中,返回结果不会被解析为跳转路径,所以如果返回json数据就必须要添加这个注解。
参考博文:https://www.cnblogs.com/xuchao0506/p/9556130.html
Error resolving template ““, template might not exist or might not be accessible by any of the confi
最新推荐文章于 2024-03-16 22:39:12 发布