How do I populate a drop-down with a list using thymeleaf and spring
Solution:
My View
List test = new ArrayList<>();
model.addAttribute("test", test);
List tests = testRepository.findAll();
model.addAttribute("tests", tests);
My HTML
<div class=”col-lg-3″ th:object=”${test}”>
<select class=”form-control” id=”testOrder” name=”testOrder”>
<option value=””>Select Test Order</option>
<option th:each=”test : ${tests}”
th:value=”${test.testCode}”
th:text=”${test.testCode}+’ : ‘+${test.testName}”></option>
</select>
</div>
Hope it helps…