Thymeleaf + Boot + AngularJS directives parser error

angularjs, spring, spring-boot, thymeleaf

Solution

Change your

@Bean
public ServletContextTemplateResolver templateResolver() { ... }

with

@Bean
public ServletContextTemplateResolver defaultTemplateResolver() { ... }

(notice default).

In your case, spring (boot) is not using your configuration for Thymeleaf thus you're getting this "strange" error about parsing non-standard attribute (since default parser is XHTML).

Problem

this should be an easy one but I can't find any solution for it. I'm using Spring Boot 1.0.2 with Thymeleaf on Jetty to support my AngularJS application. But parser throws an exception when attribute directives are used. pom.xml ``` <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>nekohtml</artifactId> <version>1.9.20</version> </dependency> ``` Thymeleaf config ``` @Configuration public class ThymeleafConfig { @Bean public ServletContextTemplateResolver templateResolver() { ServletContextTemplateResolver resolver = new ServletContextTemplateResolver(); resolver.setPrefix("/templates/"); resolver.setSuffix(".html"); resolver.setTemplateMode("LEGACYHTML5"); resolver.setCacheable(false); return resolver; } @Bean public ResourceBundleMessageSource messageSource() { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasename("messages"); messageSource.setDefaultEncoding("UTF-8"); return messageSource; } } ``` Thymeleaf is working ok but it has a problem with attribute directives like this Bootstrap UI example: ``` <div class="btn-group" dropdown is-open="true"> <button type="button" class="btn btn-primary dropdown-toggle"> Button dropdown<span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li class="divider"></li> <li><a href="#">Separated link</a></li> </ul> </div> ``` I receive this error ``` org.xml.sax.SAXParseException: Attribute name "dropdown" associated with an element type "div" must be followed by the ' = ' character. ``` Where can I tweak Thymeleaf to accept those kind of attributes? EDIT I've added nekoHTML parser for LEGACYHTML5 but still no result.

Original source