The key would be to use the iteration status mechanism along with the th:if
or th:unless
conditional attributes.
Relevant references are at:
- https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#keeping-iteration-status
- https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#simple-conditionals-if-and-unless
So in your case, it would look something along the lines of:
<option th:each="p,pStat : ${places}" th:text="${p.place_Name}" th:value="${p.id}" th:unless="${pStat.index > 7}"></option>
Edit: This answer was written for Thymeleaf 2.1 (at the time), but should work with 3.0 in the same or similar manner. See: https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html