Process Thymeleaf variable as HTML code and not text
You can use th:utext
attribute that stands for unescaped text (see documentation). Use this with caution and avoid user input in th:utext
as it can cause security problems.
<div th:remove="tag" th:utext="${n}"></div>
Display a string that contains HTML in Thymeleaf template
You can use th:utext
(unescaped text) for such scenarios.
Simply change
<p th:text="${content.text}"></p>
to
<p th:utext="${content.text}"></p>
I will suggest to also have a look into documentation here to know all about using Thymeleaf.
Thymeleaf : display a variable containing html tags
Use th:utext
instead of th:text
http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#unescaped-text
Why the Html text inside html element does not concatenate with the Thyme-leaf text? code be
That's just not how thymeleaf works. th:text
and th:utext
replace the contents of the tag.
The th:text attribute ... sets the result as the body of the host tag, effectively replacing the ... text we see in the code.
There are plenty of ways to accomplish what you want though. For example, to append at the end:
<h1 id="font">
Hello does concat with message.
<span th:utext="${message}" />
</h1>
Or
<h1 th:utext="|Hello does concat with message. ${message}|" id="font" />
Thymeleaf th:text - Put a text without removing HTML structures
I faced the same problem. The answer is th:inline='text'
This should solve your issue
<h1 th:inline="text" >
[[${header.title}]]
<small th:text="${header.subtitle}">Subtitle</small>
</h1>
or you can also use th:remove="tag"
<h1>
<span th:text="${header.title}" th:remove="tag">title</span>
<small th:text="${header.subtitle}" >Subtitle</small>
</h1>
Related Topics
How to Create a Delay in Swing
How to Use Regular Expressions in Web.Xml Url Patterns
How to Calculate the Elapsed Time of an Event in Java
Cannot Rerun Java JPAckage Installer If Already Installed, Second Time Just Exits Without Warning
How Does the Enhanced for Statement Work for Arrays, and How to Get an Iterator for an Array
Java: Why am I Required to Initialize a Primitive Local Variable
Java Key Listener in Commandline
Which Swing Component Methods Are Thread Safe
Java: Bufferedimage to Byte Array and Back
Using Variables Outside of an If-Statement
How to Include Test Classes into Maven Jar and Execute Them
Java Inheritance - Calling Superclass Method
How to Enable Wire Logging for a Java Httpurlconnection Traffic