springboot 1.5.2 thymeleaf 標簽未關閉異常解決辦法


org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="login"

原因:

Spring Boot項目渲染html的時候,因默認使用是Thymeleaf模板引擎,遇到不閉合標簽報錯,日常在編寫HTML代碼時,一般標簽都是閉合的,容易忽略的標簽包括<meta/>, <link/>, <br/>, <hr/>等等

解決辦法:

applications.properties 中添加:

spring.thymeleaf.mode=LEGACYHTML5

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" ,缺包。

解決辦法:

build.gradle 中添加

compile("net.sourceforge.nekohtml:nekohtml:1.9.22")

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM