gpt4 book ai didi

thymeleaf - 如何在 thymeleaf 中转义双引号“?

转载 作者:行者123 更新时间:2023-12-02 07:20:20 27 4
gpt4 key购买 nike

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

<td th:text='${"Value of \"" + item + "\" is \"" + value + "\"."}'></td>

我想要的结果是:
<td>Value of "apple" is "1.5".</td>

但我得到以下异常:
EL1065E: unexpected escape character.

我怎样才能做到这一点?

最佳答案

我不确定这是可能的。像这样的工作:

th:text='|Value of "${item}" is "${value}".|'

我个人会这样写:
th:text="${'Value of &quot;' + item + '&quot; is &quot;' + value + '&quot;.'}"

我认为没有办法转义双引号的原因是 thymeleaf 首先解析为 xml/html(除了 &quot; 之外没有转义)然后解析为 thymeleaf 第二个,这并没有真正有机会得到那些字符串。

关于thymeleaf - 如何在 thymeleaf 中转义双引号“?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47758513/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com