thymeleaf : display a variable containing html tags

标签 thymeleaf

在邮件中我想显示一个 java 变量:

context.setVariable("content", "Hi<br>This is a test<p></p>");

在我做的邮件模板中:

<p><span th:text="|${content}|"></span></p>

在邮件中转换为:

<p><span>Hi&lt;br&gt;this is a test&lt;p&gt;&lt;/p&gt;</span></p>

如何使变量得到很好的解释。

谢谢。

最佳答案

关于 thymeleaf : display a variable containing html tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40474680/

相关文章:

java - 根据上下文数据显示主动导航

html - 如何将所需的 HTML 属性正确设置为 TymeLeaf 页面中的输入标记?

spring-boot - Spring Boot 安全性 - Thymeleaf sec :authorize not working

java - Thymeleaf 复选框未传递值

java - 在 Spring Boot Thymeleaf Controller 返回的 View 中显示字符串

java - 直接访问对象属性 thymeleaf

java - model.addAttribute() 对于每个循环

java - 从多对多关系返回值

java - 使用 thymeleaf 将上下文绑定(bind)到 html 模板时出错

java - BindingResult 中的 Spring Boot 本地化错误消息