Thymeleaf:th:text 内的 Html 标签

问题描述 投票:0回答:2
thymeleaf
2个回答
7
投票

是的,如果您使用

th:utext
而不是
th:text
,那么您所拥有的就有效。

<h2 th:utext="'LOCATION INFO Device &lt;strong&gt;' + ${deviceKey} + ' &lt;/strong&gt;  at ' + ${deviceEventTime}" />

不过,我个人会这样格式化:

<h2>
  LOCATION INFO Device 
  <strong th:text="${deviceKey}" />
  at
  <span th:text="${deviceEventTime}">
</h2>

(可能会也可能不会,取决于您的实际要求。)


0
投票

使用这种语法是可能的 - [(${brand})] ` 所有产品(按品牌) [(${品牌})]

`

本例中的对象是 String,但您可以使用 ${object.something}。

© www.soinside.com 2019 - 2024. All rights reserved.