template might not exist or might not be accessible by any of the configured Template Resolvers
后端开发人员,在开发前端的时候遇到这个问题,记录一下,以免忘记。
错误是:{
“timestamp”: 1542883138864,
“status”: 500,
“error”: “Internal Server Error”,
“exception”: “org.thymeleaf.exceptions.TemplateInputException”,
“message”: “Error resolving template “getPortInfoList”, template might not exist or might not be accessible by any of the configured Template Resolvers”,
“path”: “/CallCenter/getPortInfoList”
}
在controller上加注解@Controller 和@RestController都可以在前端调通接口,但是二者的区别在于,当用前者的时候在方法上必须添加注解@ResponseBody,如果不添加@ResponseBody,就会报上面错误,因为当使用@Controller 注解时,spring默认方法返回的是view对象(页面)。而加上@ResponseBody,则方法返回的就是具体对象了。@RestController的作用就相当于@[email protected]的结合体
以上转自其他博客,记录自己犯过的错误!