When combining Thymeleaf's `th:each` iteration with `th:insert` or `th:replace` fragment directives, a common pitfall arises: Thymeleaf processes `th:insert`/`th:replace` before `th:each`. This means that using `th:replace` on an element that also has `th:each` causes the iteration attribute to be lost when the element is replaced by the fragment, resulting in the loop variable being undefined and a template processing error.

1m read timeFrom wimdeblauwe.com
Post cover image

Sort: