Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Thymeleaf:连接表达式_Html_Thymeleaf - Fatal编程技术网

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|" ...>