org.thymeleaf.exceptions.TemplateInputException: Error resolving template "outlet/getVersion1", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "outlet/getVersion1", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:870)
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:354)
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1370)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1116)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
在前端调服务接口,返回结果为JSON,出现此异常
异常原因:
controller中注解@Controller 和@RestController,
前者,spring默认接口方法返回的是view对象(页面),在接口方法上如果不添加@ResponseBody(返回结果为具体Object),就会报上面错误。
后者,相当于@Controller+@ResponseBody的结合体,返回的是具体Object