thymeleaf下拉菜单、单选按钮、多选按钮的数据回显
1、单选按钮
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性  别:</label>
<div class="formControls col-xs-8 col-sm-9 skin-minimal">
<div class="radio-box">
<input name="gender" type="radio" th:attr ="checked=${Gender()=='1'?true:false}" id="sex-1"  value="0">
<label >男</label>
</div>
<div class="radio-box">
<input type="radio" th:attr ="checked=${Gender()=='0'?true:false}" id="sex-2" name="gender" value="1">
<label >⼥</label>
</div>
</div>
</div>
2、下拉框
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>⾓  ⾊:</label>
<div class="formControls col-xs-8 col-sm-9">
<span class="select-box">
<select class="select" id="rol" size="1" name="city" onchange="changerole()">
<option th:selected="${Roleid() Role_id()}" th:each="role:${rolelist}">[[${lename}]]</option>
</select>
</span>
</div>
<input id="role" value="" name="role">
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权  限:</label>
<div class="formControls col-xs-8 col-sm-9">
<span class="select-box">
<select class="select" id="pri"  name="" onchange="changeprivilege()">
<option th:selected="${privilege.pid Privilege()}" th:each="privilege:${pList}">[[${privilege.pname}]]</option>
</select>
</span>
</div>
<input id="privilege" value="" name="privilege">
</div>
3、默认选中第⼀个
<input type ="radio" name="repaymentType"
th:each ="repaymentType,repaymentState:${repaymentTypeList}"
th:value="${repaymentType.dictName}"
th:text ="${repaymentType.dictName}"
th:attr ="checked=${repaymentState.index==0?true:false}">
4、多选
//多选回显
<div class="row cl">
<input type ="checkbox" name="role"
th:each ="role : ${roleList}"
th:value="${leName}"
thymeth:text ="${leName}"
th:attr ="checked=${leName)?true:false}"> </div>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。