for loop in thymeleaf

Viewed 45565

How can I do the following (java):

for(int i = 0; i < 81 ; i+=20){
   //Should loop through 5 times!
}

in Thymeleaf?

I've tried this:

<option th:each="i : ${#numbers.sequence( 1, 81/20)}">
   <p th:text="${ i }"></p> <!-- THIS loops 4 times, instead of 5 -->
</option>

The problem is that it is not as accurate as the java piece of code. How to do this?

4 Answers

The 1st value is the beginning of count, the 2nd is the maximum value and the 3rd is the incremental value

${#numbers.sequence( 1, 4, 1)}
Related