spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException

Posted 知识铸就三叉戟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException相关的知识,希望对你有一定的参考价值。

技术分享图片
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的作用就相当于@[email protected]的结合体

以上是关于spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException的主要内容,如果未能解决你的问题,请参考以下文章

spring-boot-thymeleaf

Spring Boot中使用thymeleaf

spring boot整合Thymeleaf

Spring Boot2:使用Spring Boot结合Thymeleaf模板引擎使用总结

Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例

Spring Boot 学习笔记--整合Thymeleaf