Sunday, February 8, 2015

org.xml.sax.SAXParseException: Attribute name "attribute-without-value" associated with an element type "div" must be followed by the ' = ' character.

When you use Thymeleaf in Spring Boot,

you can encounter the following exception:

org.xml.sax.SAXParseException: Attribute name "attribute-without-value" associated with an element type "div" must be followed by the ' = ' character.

In Spring Boot, Thymeleaf mode's default value is HTML5.

So you should change the mode to LEGACYHTML5

by adding the following property in your 'application.properties':

spring.thymeleaf.mode=LEGACYHTML5

And you should add the following dependency in your 'build.gradle':

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

If not, you will encounter the following exception:

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.

You can find a sample for this as follows:

https://github.com/izeye/samples-spring-boot-branches/tree/thymeleaf

Reference:
http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

No comments:

Post a Comment