I have a state dropdown menu which is working. I populate it with all the states and I get which state is selected. Now I need to rework it and make it available to select multiple states. I need a hint how can I get an arraylist of all the states that are multiple selected
<label for="state" class="label">State</label>
<select class="w-input" maxlength="256" name="state" data-
name="state" id="state" multiple="multiple">
<option th:each="state : ${states}" th:value="${state.getName()}" th:text="${state.getName()}" th:selected="${state.getName()} == ${questionnaire.getState()}"></option>
</select>
my controller:
model.addAttribute("states", stateService.getAllStates());
questionnaire.setState(body.get("state"));
I am looking for a way to set multiple states as an arraylist of Strings, because now I am getting only one String as a value, but not all the selected