This post is about fixing “Fatal error during parsing” HTML5 by Thymeleaf with Spring Boot.
Using Spring Boot 1.5.10.RELEASE with Thymeleaf and HTML5, it is possible to meet the following error:
org.xml.sax.SAXParseException: The element type "meta" must be terminated by the matching end-tag "</meta>".
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Page Title</title> </head> <body> Page Body </body> </html>
It happens because spring-boot-starter-thymeleaf:1.5.10.RELEASE has default dependency on org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE. Fix needs updated version of Thymeleaf.
To make this, it is enough to define the following 2 properties in pom.xml:
<properties> ... <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version> <thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version> </properties>
Or, in case of using Gradle, add them in build.gradle:
ext['thymeleaf.version'] = '3.0.9.RELEASE' ext['thymeleaf-layout-dialect.version'] = '2.3.0'