Issue
I want to display the following row in an html table:
"$num out of $totalCount"
for example num=5
and totalCount=8
I want to see in the table 5 out of 8
here is my code:
...
<tr>
<td th:text="${num} out of ${totalCount}" />
</tr>
...
I added num
and totalCount
as models in the controller.
I am getting the following error:
Could not parse as expression: "${num} out of ${totalCount}"
What is the right syntax to do so?
Solution
There are a few options for string concatenation in Thymeleaf. See String concatenation with Thymeleaf for an overview.
In this case, you can use something like this:
<td th:text="|${num} out of ${totalCount}|" />
Answered By - Wim Deblauwe
Answer Checked By - Robin (JavaFixing Admin)