springboot 用thymeleaf 出现的错误问题

 

Error resolving template template might not exist or might not be accessible

 

原因是因为 thymeleaf 采用严格的HTML5 规则,必须要有结束标签。否则会包上面的错误

 

解决办法

spring:

  #声明thymeleaf使用非严格的html。
  thymeleaf:
    content-type: text/html
    mode: LEGACYHTML5
    cache: false

 

会出现如下错误:

springboot 用thymeleaf 出现Error resolving template template might not exist or might not be acceacce问题

 

缺少依赖

<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
    <version>1.9.22</version>
</dependency>

 

如果还未解决,可能原因是:templates 文件名是否正确

controller中 return "/index" 页面不能有 /

以上方法无解决办法:那只能是springboot版本问题了。

我在 

1.5.17.RELEASE 这个版本下,以上都改过了,还是报模板找不到错误。

后来将springboot版本 改为  

2.1.0.RELEASE  成功运行了。

 

 

相关文章:

  • 2021-10-27
  • 2021-05-09
  • 2021-09-14
  • 2021-04-16
  • 2021-07-19
  • 2021-10-08
  • 2021-12-03
  • 2021-08-15
猜你喜欢
  • 2021-09-30
  • 2021-04-22
  • 2021-10-04
  • 2021-10-14
  • 2021-05-16
  • 2021-12-07
  • 2021-08-15
相关资源
相似解决方案