Html Thymeleaf:连接表达式
我有这个表情Html Thymeleaf:连接表达式,html,thymeleaf,Html,Thymeleaf,我有这个表情 <h2 class="topmargin_0 bottommargin_30" th:text="${user.name} || ${user.age} || ' years old'"></h2> 要连接,请使用+: <h2 th:text="${user.name} + ${user.age} + 'years old'" ...> 更新: 我写这篇文章是为了深入展示所有可能的字
<h2 class="topmargin_0 bottommargin_30" th:text="${user.name} || ${user.age} || ' years old'"></h2>
要连接,请使用
+
:
<h2 th:text="${user.name} + ${user.age} + 'years old'" ...>
更新:
我写这篇文章是为了深入展示所有可能的字符串连接选项。是一个很好的参考页面,可以总结很多核心Thymeleaf语法。这里包括字符串连接。如果你也在使用Spring,那么它对SpEL来说是一个很好的参考。
<h2 th:text="${user.name} + ${user.age} + 'years old'" ...>
<h2 th:text="|${user.name} ${user.age} years old|" ...>