【发布时间】:2020-12-30 06:23:42
【问题描述】:
我有这个表情
<h2 class="topmargin_0 bottommargin_30" th:text="${user.name} || ${user.age} || ' years old'"></h2>
但当我运行应用程序时。我有这个错误:
Could not parse as expression:
【问题讨论】:
我有这个表情
<h2 class="topmargin_0 bottommargin_30" th:text="${user.name} || ${user.age} || ' years old'"></h2>
但当我运行应用程序时。我有这个错误:
Could not parse as expression:
【问题讨论】:
要连接,请使用+:
<h2 th:text="${user.name} + ${user.age} + 'years old'" ...>
或者使用|:
<h2 th:text="|${user.name} ${user.age} years old|" ...>
更新: 我写了a blog post 来深入展示所有可能的字符串连接选项。
【讨论】: