Thymeleaf Error resolving template [index],template might not exist or might not be accessible问题解决
问题描述:
# 后缀 spring.thymeleaf.prefix=classpath: /templates # 模板格式 spring.thymeleaf.mode=HTML5 spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.content-type=text/html spring.thymeleaf.suffix=.html # 开发时关闭缓存,不然没法看到实时页面 spring.thymeleaf.cache=false
以上为我的thymeleaf配置,出现以下报错:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
问题分析:
出现这个问题要不就是index.html不存在,要不就是application.properties文件里面的spring.thymeleaf.prefix配置错误
问题解决:
1、查看index.html文件是否存在
2、查看application.properties文件里面的spring.thymeleaf.prefix配置是否正确
正确代码示范:
spring.thymeleaf.prefix=classpath:/templates/
(1)查看classpath:和/templates/之间是否多了空格
以下是错误代码示范:
spring.thymeleaf.prefix=classpath: /templates/
(2)查看spring.thymeleaf.prefix=classpath:/templates/末尾是否少了/符合
以下是错误代码示范:
spring.thymeleaf.prefix=classpath:/templates
(3)查看templates文件夹是否存在
上一篇:
多线程四大经典案例