user1260928
user1260928

Reputation: 3439

Thymeleaf : display a variable containing html tags

In a mail I want to display a java variable :

context.setVariable("content", "Hi<br>This is a test<p></p>");

In the mail template I do :

<p><span th:text="|${content}|"></span></p>

In the mail this is converted in :

<p><span>Hi&lt;br&gt;this is a test&lt;p&gt;&lt;/p&gt;</span></p>

How to make the variable well interpretated.

Thank you.

Upvotes: 5

Views: 18280

Answers (1)

Metroids
Metroids

Reputation: 20487

Use th:utext instead of th:text

http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#unescaped-text

Upvotes: 13

Related Questions