template might not exist or might not be accessible by any of the configured Template Resolvers

深藏阁楼爱情的钟 2021-09-26 05:30 392阅读 0赞

application.properties配置文件

  1. spring.thymeleaf.prefix=classpath:/templates/
  2. spring.thymeleaf.suffix=.html
  3. spring.thymeleaf.mode=LEGACYHTML5
  4. #spring.thymeleaf.encoding=UTF-8
  5. #spring.thymeleaf.content-type=text/html # ;charset=<encoding> is added
  6. spring.thymeleaf.cache=false

springboot使用thymeleaf时报html没有结束标签

在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错!解决办法如下:

1、你可以使用严格的标签,也就是每个标签都有结束标签,这种可能比较麻烦

2、在application.properties中增加spring.thymeleaf.mode=LEGACYHTML5,即声明thymeleaf使用非严 格的html。

maven依赖如下

  1. <dependency>
  2. <groupId>net.sourceforge.nekohtml</groupId>
  3. <artifactId>nekohtml</artifactId>
  4. <version>1.9.22</version>
  5. </dependency>

现在就可以正常访问了。

发表评论

表情:
评论列表 (有 0 条评论,392人围观)

还没有评论,来说两句吧...

相关阅读