Error resolving template [sys/prod/prod/list], template might not exist or might not be accessible by any of the configured Template Resolvers

新的商城模板调试接口,一个商品列表的接口调用,返回报错

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [sys/prod/prod/list], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
    at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362)
    at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)

问题原因:

 

 

 

 

 

 

在controller上加注解@Controller 和@RestController都可以在前端调通接口,但是二者的区别在于,当用前者的时候在方法上必须添加注解@ResponseBody,

如果不添加@ResponseBody,就会报上面错误,因为当使用@Controller 注解时,spring默认方法返回的是view对象(页面)。

而加上@ResponseBody,则方法返回的就是具体对象了。

@RestController的作用就相当于@Controller+@ResponseBody的结合体

修改为@RestController 后正常

 

posted @   贾斯丁哔哔  阅读(118)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示