Home > OS >  how to display 2 spring models in the same html table row using thymeleaf?
how to display 2 spring models in the same html table row using thymeleaf?

Time:11-09

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?

CodePudding user response:

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}|" />
  • Related