如何在包含引号的内联样式的百里叶中显示HTML

发布于 2025-02-12 03:45:22 字数 618 浏览 1 评论 0原文

我想在百里叶模板中显示一些HTML样式文本。要显示html,我正在使用th:utext =“ $ {myVariable}”,但是,我遇到了一个错误:

元素类型“ span”必须随后是任一属性规格,“>”或“/>”。

可能是因为HTML看起来像这样:

<p><span style="color: rgba(0,0,0,0.85);background-color: rgb
(255,255,255);font-size: 14px;font-family: -apple-system,
BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto
Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji;">This is my styled text.</span>&nbsp;</p>

如您所见,它具有包含“”的内联样式,因此Thymeleaf无法处理。知道我该如何解决这个问题?

I've some html styled text that I want to display in the Thymeleaf template. To display the html, I'm using th:utext="${myVariable}", however, I'm getting an error:

Element type "span" must be followed by either attribute specifications, ">" or "/>".

It's may be because the html looks like this:

<p><span style="color: rgba(0,0,0,0.85);background-color: rgb
(255,255,255);font-size: 14px;font-family: -apple-system,
BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto
Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji;">This is my styled text.</span> </p>

As you can see, it has inline styles that are contained with "", so thymeleaf is unable to process it. Any idea how can I resolve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文