【发布时间】:2017-11-24 09:59:06
【问题描述】:
我得到一个已经有如下百里香标签的字符串:
String html = "<span th:text="${fisrtText}"></span> Indicative Terms for a <span th:text="${currency}"></span><span th:text="${amount}"></span>M <span th:text="${type}"></span> Facility";
我将上面的字符串设置为上下文变量:
context.setVariable("topSection", html);
我将上下文变量设置为用于替换上述字符串中的标签的值:
org.thymeleaf.context.Context context = new org.thymeleaf.context.Context();
context.setVariable("fisrtText", "This is fisrt Text");
context.setVariable("currency", "$");
context.setVariable("amount", 256.10);
context.setVariable("type", "Loan");
现在在 template.html 我试图得到它如下:
<span th:utext="@{__${topSection}__}"></span>
我希望将 html 字符串替换为上下文中可用的值。但它返回与它相同的 html 没有任何处理:
<span th:text="${fisrtText}"></span> Indicative Terms for a <span th:text="${currency}"></span><span th:text="${amount}"></span>M <span th:text="${type}"></span> Facility"
任何帮助将不胜感激。
【问题讨论】: