如何转义双引号 "在百里香? [英] How to escape double quote " in thymeleaf?
本文介绍了如何转义双引号 "在百里香?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Thymeleaf 的字符串中放置双引号,我有以下形式:
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>
我想要的结果是:
<td>Value of "apple" is "1.5".</td>
但我得到以下异常:
EL1065E: unexpected escape character.
我该怎么做?
推荐答案
我不确定这是否可行.像这样的工作:
I'm not sure it's possible. Something like this works:
th:text='|Value of "${item}" is "${value}".|'
我个人会这样写:
th:text="${'Value of "' + item + '" is "' + value + '".'}"
我认为没有办法转义双引号的原因是 thymeleaf 首先解析为 xml/html(除了 "
之外没有转义),然后解析为 thymeleaf第二个实际上没有机会获得这些字符串.
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.
这篇关于如何转义双引号 "在百里香?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文