本文主要是介绍Error resolving template [xxx], template might not exist or might not be accessible by any of the co,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Error resolving template [xxx], template might not exist or might not be accessible by any of the configured Template Resolvers
springboot运行成功之后,访问页面报错,反复查看代码,都没有错误,最后原因是因为给thymeleaf的默认设置进行了自定义设置,但是自定义的时候设置的值又是本来的默认值,导致程序报错:
2020-12-13 16:56:04.753 ERROR 37468 --- [nio-8888-exec-1] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8888-exec-1] Exception processing template "index": Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
其实默认设置有默认值的,自身项目没有改动的,根本不需要修改或者自定义这些设置。spring.thymeleaf下的 prefix、suffix、check-template-location、mode都是有默认值的,如果你的application.properties或者application.yml中设置了这些属性,但是值是默认值的话,删掉这些设置,就不会报错了。
application.properties
# 如果项目没有更改以下属性值,则properties中不需要设置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.suffix=html
spring.thymeleaf.mode=HTML
这篇关于Error resolving template [xxx], template might not exist or might not be accessible by any of the co的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!