I am using Spring Boot for an MVC application, and my view technology is Thymeleaf. One of the things I need to do is copy the HTML of an existing website (not my doing...) and render it using Thymeleaf. However, some of the website's source HTML contain unclosed HTML tags (such as <meta>
, <link>
, <input>
), or HTML tags with elements not surrounded by quotes, for example:
<div id=1></div>
instead of
<div id="1"></div>
Of course in the browser this works... But Thymeleaf will not allow this and doesn't serve the page. Is there any way to allow more lenient rules for this? I've searched Thymeleaf's documentation and Spring Boot reference and have found no answer.
Just for clarification - I've not even configured my own beans for Thyemeleaf, just added it to the classpath via maven as one of the spring-boot-starters. So right now these are default settings.
Spring Boot is an open source Java-based framework used to create a micro Service. It is developed by Pivotal Team and is used to build stand-alone and production ready spring applications.
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications. It's a Java-based framework used to create a microservice ( microservice is defined as the small services that work together.
Spring Boot is a backend framework that has become a major player in the enterprise Java ecosystem. It lets Java developers start building web applications quickly, without fuss.
Spring Boot is an open-source tool that makes it easier for developers to create standalone digital products and production-ready spring applications including Java applications and web services. It uses a micro framework, which makes it most useful for creating microservices for websites and mobile apps.
Spring Boot 1.5.3 supports Thymeleaf 3. Thymeleaf 3 has full html5 markup support.
Add following lines to your pom.xml
to override Thymeleaf version in Spring boot and you'll be able to use unclosed tags.
<properties>
<thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version>
...
</properties>
Everything should be xthml format
For example ;
HTML LINK
<link rel="stylesheet" type="text/css" href="mystyle.css">
THYMELEAF LINK SHOULD BE ending with "/> "
<link rel="stylesheet" href="print.css" media="print" type="text/css" />
HTML META
<meta charset="UTF-8">
THYMELEAF META SHOULD BE ending with "/>"
<meta charset="utf-8"/>
Samples
<input type="text" name="lastname" disabled /> wrong
<input type="text" name="lastname" disabled="disabled" /> correct
otherwise pages will not be displayed because of xhmtl rules applied.
Please have a look at the link , avoid this kind of mistakes HTML and XHTML
On the other hand when the page is return to browser you will see xhtml rules converts to html format again. But the actually page it run on a server before sending client thymeleaf xhtml rules are applied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With