I have a spring boot application with frontend using thymeleaf and bootstrap. I have dropdown list on a questionnaire, which is populated with a list of options. But when I create a new questionnaire or I always get first option as selected of the list instead of "Select Answer" which should be default if no option is selected.
But I want by default "Select Answer to be selected"
The html for this dropdown section is as follows:
<td class="col-4">
<select th:field="*{questionnaire.questions[__${iStat.index}__].possibleAnswers[0].id}" class="form-control">
<!-- <option th:value="0" th:selected="true">Select Answer</option>-->
<option value="0" selected="selected" >Select Answer</option>
<option th:each="possibleAnswer : ${question.getPossibleAnswers()}"
th:value="${possibleAnswer.id}"
th:text="${possibleAnswer.text}"></option>
</select>
</td>
Could anyone please suggest how can make this dropdown select "Select Answer" as default.