I've been messing around with Spring MVC 5 and Thymeleaf 3.0 lately and have noticed something strange. I've started to implement a dropdown list from the tutorial on the site and have noticed some performance issues. If I use the following code, it takes around 5.5 seconds for my page to render a dropdown list of about 100 items.
<select th:field="*{item}">
<option th:each="item : ${items}"
th:value="${item.getId()}"
th:text="${item.getValue()}"></option>
</select>
On the other hand, if I use the following code, my page renders in about 150ms.
<div th:each="item : ${items}">
<span th:text="${item.getId()}"/>
<span th:text="${item.getValue()}"/>
</div>
I've looped through the list of items in my controller and printed out the values to see if their was any slowdown with getting data from the database, but grabbing items from the controller happened instantly. I've also tried rendering different html elements in the select tag for testing purposes and even though it isn't valid html, it still renders the page quickly.
The only time I experience an extreme amount of lag on page rendering is when I use a th:each inside of a select tag on options. Does Thymeleaf handle select tags differently? I would think that if the same list of items, calling the same methods can render a page in 130ms by looping through divs, it should be able to create options at a comparable rate, instead of taking 5.5 seconds.
Has anyone encountered an issue like this before? I did some searching and found that there were performance issues looping in Thymeleaf, but those cases had upwards of 100,000 records, where my list is about 100 items. Any help would be greatly appreciated.
Update
I've narrowed down the issue to performing poorly on th:field="*{item}". If I run the following code, the page loads instantly.
<select>
<option th:each="item : ${items}"
th:value="${item.getId()}"
th:text="${item.getValue()}"></option>
</select>
Once I try to bind the select using th:field="*{item}", the page hangs for around 5.5 seconds. Is there any reason why binding using th:field would cause an issue with lag?