template might not exist or might not be accessible by any of the configured Template Resolvers

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的作用就相當於@Controller+@ResponseBody的結合體

以上轉自其他博客,記錄自己犯過的錯誤!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章