I am building a project that has values in a Java HashMap
and I would like to place it into my front-end Thymeleaf. Though I looked up some code on their Documentation and Stack Overflow, I can't seem to find a good answer to my question. I have some code below that does not pass the values and I am wondering where I made the mistake at.
So for all the keys, I am trying to make them a optgroup
. For the values, I want to make it a option
. Any help would be appreciated.
HTML:
<div class="row">
<div class="col col-lg-9 search-bar">
<div class="form-group">
<label>Type:</label>
<select class="js-example-basic-single2" id="selectData2">
<optgroup th:each="tierList : ${hmap}"
th:label="${tierList.key}">
<option th:each=" system : ${tierList.value}"
th:value="${system}"
th:selected="${system}"
th:text="${system}">
</option>
</optgroup>
</select>
</div>
</div>
</div>