I want to put double quotes in a String in Thymeleaf, I have something of the form:
<td th:text='${"Value of \"" + item + "\" is \"" + value + "\"."}'></td>
The result i want is:
<td>Value of "apple" is "1.5".</td>
But I get the following exception:
EL1065E: unexpected escape character.
How can I do this?
I'm not sure it's possible. Something like this works:
th:text='|Value of "${item}" is "${value}".|'
I would personally write it like this:
th:text="${'Value of "' + item + '" is "' + value + '".'}"
I think the reason there is no way to escape double quotes, is that thymeleaf is first parsing as xml/html (which has no escape other than "
) and then parsing as thymeleaf second which doesn't really have a chance to get at those strings.