0

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?

Shinzoo
  • 21
  • 1
  • 6
  • Potential duplicate: http://stackoverflow.com/questions/20633118/for-loop-in-thymeleaf – Bas Apr 23 '17 at 10:11

2 Answers2

2

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.

riddle_me_this
  • 8,575
  • 10
  • 55
  • 80
1

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>
bunbun
  • 2,595
  • 3
  • 34
  • 52
Tanmoy Mandal
  • 466
  • 4
  • 14