I add one variable to model called numberOfPages and I want to foor over this variable. I mean I want to achieve something like this:
for(int i = 1; i <= numberOfPages; i++)
How can I do this?
I add one variable to model called numberOfPages and I want to foor over this variable. I mean I want to achieve something like this:
for(int i = 1; i <= numberOfPages; i++)
How can I do this?
You may mean something like this:
<div th:each="pageNumber : ${numberOfPages}">
<span th:text="${pageNumber}">Some default text here</span>
</div>
You can alternatively use the th:block
and th:remove="tag"
notation if you don't want tags to show.
May be you are looking for this:
<div th:each="page : ${#numbers.sequence( 1, __${numberOfPages}__)}">
<span th:text="${page}">Some default text here</span>
</div>