【问题标题】:Why the Html text inside html element does not concatenate with the Thyme-leaf text? code be [duplicate]为什么 html 元素中的 Html 文本不与 Thyme-leaf 文本连接?代码是[重复]
【发布时间】:2019-12-22 09:03:48
【问题描述】:

我是 thyme leaf 的新手,我正在尝试将 java 代码中的文本与 html 连接起来。我在下面显示。

<h1 th:utext="${message}" id="font">
        Hello does not concat with message.
        </h1>

【问题讨论】:

    标签: thymeleaf


    【解决方案1】:

    这不是百里香的工作原理。 th:textth:utext 替换标签的内容。

    th:text 属性 ... 将结果设置为主机标签的主体,有效地替换了我们在代码中看到的 ... 文本。

    不过,有很多方法可以实现您想要的。例如,在末尾追加:

    <h1 id="font">
        Hello does concat with message.
        <span th:utext="${message}" />
    </h1>
    

    或者

    <h1 th:utext="|Hello does concat with message. ${message}|" id="font" />
    

    【讨论】:

      猜你喜欢
      • 2018-07-12
      • 1970-01-01
      • 2015-10-25
      • 2015-06-10
      • 1970-01-01
      • 2012-04-14
      • 1970-01-01
      • 2010-10-14
      • 1970-01-01
      相关资源
      最近更新 更多