根据数据库数据动态设置select标签的默认值
根据数据库数据动态设置select标签的默认值
thymeleaf模板引擎下使用th:selected比较数据库的值与option中value的值是否匹配。
<div class="ui raised very padded text container segment" th:each="info:${InfoList}">
<select class="ui fluid dropdown" name="Sex" placeholder="Sex">
<option th:selected="${info.sex}=='Man'" value="Man">Man</option>
<option th:selected="${info.sex}=='Women'"value="Women">Women</option>
</select>
</div>

浙公网安备 33010602011771号