Reputation: 2113
I have this expression
<h2 class="topmargin_0 bottommargin_30" th:text="${user.name} || ${user.age} || ' years old'"></h2>
butn when I run the app. I have this error:
Could not parse as expression:
Upvotes: 0
Views: 1102
Reputation: 26858
To concatenate, use +
:
<h2 th:text="${user.name} + ${user.age} + 'years old'" ...>
Or use |
:
<h2 th:text="|${user.name} ${user.age} years old|" ...>
UPDATE: I wrote a blog post to show all possible string concatentation options in depth.
Upvotes: 2