thymeleaf回显数据

1.单选框:

<-- showState为值 -->
<input type="radio"  name="showState"  th:value="0" th:checked="${showState==0}"/>显示
<input type="radio"  name="showState"  th:value="1" th:checked="${howState==1 }"/>隐藏
<-- showState为对象属性 -->
<input type="radio"  name="showState"  th:value="0" th:field="*{showState}"/>显示
<input type="radio"  name="showState"  th:value="1" th:field="*{showState}"/>隐藏

2.下拉框:

<form class="form-horizontal m" id="form-person-edit" th:object="${person}">
        <input id="user" name="user" th:field="*{user}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">用户</label>
            <div class="col-sm-8">
                <select name="group" class="form-control" th:field="*{user}" >
                    <option value="">请选择用户</option>
                    <option th:each="u:${personlist}" th:value="${u.user}" th:text="${u.name}"></option>
                </select>
            </div>
        </div>
 
    </form>

3.input回填

<div class="form-group">
    <label class="col-sm-1 control-label">客户姓名:</label>
    <div class="col-sm-3">
        <input id="customerName" name="customerName" th:value="${customer.customerName}" class="form-control" type="text">
    </div>
    
</div>

4.时间

<div class="form-group">
    <label class="col-sm-1 control-label">出生日期:</label>
    <div class="col-sm-3">
        <input type="text" class="laydate-icon layer-date form-control" id="birthday" name="birthday" th:value="${customer.birthday}==null?null:${#dates.format(customer.birthday,'yyyy-MM-dd')}" οnclick="laydate({istime: true, format: 'YYYY-MM-DD'})" style="background-color: #fff;" readonly="readonly" />
    </div>
</div>
发布了105 篇原创文章 · 获赞 29 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/weixin_45678915/article/details/104720444