報錯信息:org.thymeleaf.exceptions.TemplateInputException: Error resolving template "xxxxx", template might not exist or might not be accessible by any of the configured Template Resolvers
運行提示找不到模板時,
在controller類上加注解@Controller 和@RestController都可以在前端調通接口,但是二者的區別在於,當用前者的時候在方法上必須添加注解@ResponseBody,如果不添加@ResponseBody,就會報上面錯誤,因為當使用@Controller 注解時,spring默認方法返回的是view對象(頁面)。而加上@ResponseBody,則方法返回的就是具體對象了。@RestController的作用就相當於@Controller+@ResponseBody的結合體
————————————————
版權聲明:本文為CSDN博主「你瞅啥瞅你咋地」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/PubliclyAccessible/article/details/79726360