如何在百里香中转义双引号?

hil*_*ias 2 thymeleaf

我想在Thymeleaf的字符串中加上双引号,我有以下形式:

<td th:text='${"Value of \"" + item + "\" is \"" + value + "\"."}'></td>
Run Code Online (Sandbox Code Playgroud)

我想要的结果是:

<td>Value of "apple" is "1.5".</td>
Run Code Online (Sandbox Code Playgroud)

但是我得到以下异常:

EL1065E: unexpected escape character.
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Met*_*ids 7

我不确定是否有可能。像这样的作品:

th:text='|Value of "${item}" is "${value}".|'
Run Code Online (Sandbox Code Playgroud)

我会这样写:

th:text="${'Value of &quot;' + item + '&quot; is &quot;' + value + '&quot;.'}"
Run Code Online (Sandbox Code Playgroud)

我认为没有办法转义双引号的原因是,thymeleaf首先解析为xml / html(除以外没有其他转义&quot;),然后解析为thymeleaf第二,实际上没有机会获取这些字符串。