4

the angularjs feature called directive cause to problems in spring mvc. If I use thymeleaf to render a html with elements such

<div ui-view autoscroll="false"></div>

i got a error like

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

is there an elegant workaround or should I use something else than thymeleaf?

Edit:

Many thanks for your answers, they helped me a lot.

Either you code xml or you use some workaround. open your application.properties and add following

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
1

1 Answer 1

9

Just put the below code. basically what it is saying is that every attribute in HTML should have a value. When the browser renders it, it will anyway look like below.

<div ui-view="" autoscroll="false"></div>

Update: You can also use directive in a class or as an element.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your comment. Is there a more elegant way to get rid of it instead change html code? coding directives like ui-view without any suffix is the common way.
To avoid this, you can use the directive as class or element name in which case it should work more elegantly. ui-view="" is really the correct and more generic way really because it conforms to XML standards too. What is really limiting you is "thymeleaf" because it is again conforming to the correct XML way. Not much you can do there unless you dont want validation from thymeleaf in which case you might have to ask the thymeleaf community. Just a note here, there is no "angular" way of using directives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.