Skip to content Skip to sidebar Skip to footer

Adding Html Tags Using Th:text In Thymeleaf

How can I add HTML tags into a th:text so the tags become visual? An example of this would be the following: A view variable called htmlcode gets injected with the value b

Solution 1:

I was able to solve this issue by using th:utext instead of th:text. This way, the HTML tags are added unescaped. Obviously, this has to be used with caution, to prevent XSS attacks.


Post a Comment for "Adding Html Tags Using Th:text In Thymeleaf"