单选按钮和 下拉框 的 thymeleaf的回显


  <div class="layui-inline">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-inline">
                <input type="radio" name="sex" value="男" title="男" th:if="${staff.sex ne null}" th:field="${staff.sex}">
                <input type="radio" name="sex" value="女" title="女" th:if="${staff.sex ne null}" th:field="${staff.sex}">
                <input type="radio" name="sex" value="男" title="男" th:if="${staff.sex eq null}" th:checked="checked">
                <input type="radio" name="sex" value="女" title="女" th:if="${staff.sex eq null}">
            </div>
        </div>

thymeleaf 的方式回显 单选按钮


<select name="fireboxroltype">
    <option value="">请选择</option>
    <option th:selected="${abc.ficontroltype eq item.name}" th:each="item:${model}"
            th:text="${item.name}"
            th:value="${item.code}"></option>
</select>

走两个model,注意selected中的两个name,第一个name必须在第二个name中能找到对应的name值。否则无法取得对应的code值,并且无法回显

猜你喜欢

转载自blog.csdn.net/weixin_38728273/article/details/88413828