How to generate svg inside thymeleaf template

I would like to create a html page using spring thymeleaf template. The page must contain a section <svg>

. Section content is dynamically generated from java code. I tried to use the syntax [[${var}]]

but it didn't work.

+3


source to share


1 answer


Thymeleaf is quite flexible, you can use th:utext

to insert svg content like this:



<svg width="300px" height="300px" xmlns="http://www.w3.org/2000/svg" th:utext="${var}">
</svg>

      

+2


source







All Articles