1. 程式人生 > >spring boot + thymeleaf 報錯 org.thymeleaf.exceptions.TemplateInputException

spring boot + thymeleaf 報錯 org.thymeleaf.exceptions.TemplateInputException

serve pac result http 返回 render lba div ble

技術分享圖片
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/verifyPassword", template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
    at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
    at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1286)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
技術分享圖片

以上錯誤,是個低級錯誤,我們都知道,在controller上加註解@Controller 和@RestController都可以在前端調通接口,但是二者的區別在於,當用前者的時候在方法上必須添加註解@ResponseBody,如果不添加@ResponseBody,就會報上面錯誤,因為當使用@Controller 註解時,spring默認方法返回的是view對象(頁面)。而加上@ResponseBody,則方法返回的就是具體對象了。@RestController的作用就相當於@Controller+@ResponseBody的結合體

spring boot + thymeleaf 報錯 org.thymeleaf.exceptions.TemplateInputException