Arthur
Arthur

Reputation: 3473

Thymeleaf - How to pass HTML to the div?

How to pass HTML from a variable to a div?

I have code

<div class="content" th:text="${ourService.getShortText()}" />

But it shows not HTML in the div, but escaped HTML as div text. How to pass the variable's value not as an escaped text, but as inner HTML of the div?

Upvotes: 12

Views: 15131

Answers (1)

Arthur
Arthur

Reputation: 3473

The solution is as follows:

<div class="content" th:utext="${ourService.getShortText()}" />

Upvotes: 24

Related Questions