根据数据库数据动态设置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>
posted @ 2021-12-07 16:43  叶榆不业余  阅读(354)  评论(0)    收藏  举报