zoukankan      html  css  js  c++  java
  • springboot使用thymeleaf 解析异常


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

      1、你可以使用严格的标签,也就是每个标签都有结束标签,这种可能比较麻烦
      2、在application.properties中增加

    spring.thymeleaf.prefix=classpath:templates/
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.mode=LEGACYHTML5
    spring.thymeleaf.encoding=UTF-8
    spring.thymeleaf.content-type=text/html
    spring.thymeleaf.cache=false

      即声明thymeleaf使用非严格的html。启动之后访问页面会报如下错误:

      

    org.thymeleaf.exceptions.ConfigurationException: Cannot perform conversion to XML from 
    
    legacy HTML: 
    The nekoHTML library is not in classpath. nekoHTML 1.9.15 or newer is required for 
    
    processing templates in
    "LEGACYHTML5" mode [http://nekohtml.sourceforge.net]. Maven spec: 
    
    "net.sourceforge.nekohtml::nekohtml::1.9.15".
    IMPORTANT: DO NOT use versions of nekoHTML older than 1.9.15.

      上面的异常说的是需要依赖nekoHTML 1.9.15 or newer的版本。pom.xml中添加依赖如下

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

      

  • 相关阅读:
    dotnet run urls=http://*:8080
    内敛声明变量
    C#反射赋值(更新时用)
    mysql---auto_increment=10啥意思呢?
    vscode--代码折叠与展开
    联想启天M410台式机的清除BIOS密码
    AntD是什么?
    react-router-dom 中文文档
    Recoil是什么?
    sql server查看建表的创建代码?
  • 原文地址:https://www.cnblogs.com/QW-lzm/p/8275537.html
Copyright © 2011-2022 走看看