项目中用到radio数据回显:
<div class="form-group">
<label class="col-sm-3 control-label">是否结束:</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" value="0" name="caseFlag"
th:attr="checked=${proMpStage.caseFlag=='0'?true:false}">是
</label>
<label class="radio-inline">
<input type="radio" value="1" name="caseFlag"
th:attr="checked=${proMpStage.caseFlag=='1'?true:false}">否
</label>
</div>
</div>
一、radio
<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=${user.getGender()=='1'?true:false}" id="sex-1" value="0">
<label >男</label>
</div>
<div class="radio-box">
<input type="radio" th:attr ="checked=${user.getGender()=='0'?true:false}" id="sex-2" name="gender" value="1">
<label >女</label>
</div>
</div>
</div>
二、select
<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 style="height: 50px;" th:selected="${role.getRoleid() eq user.getRole_id()}" th:each="role:${rolelist}">[[${role.rolename}]]</option>
</select>
</span>
</div>
<input style="display: none" 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 style="height: 50px;" th:selected="${privilege.pid eq user.getPrivilege()}" th:each="privilege:${pList}">[[${privilege.pname}]]</option>
</select>
</span>
</div>
<input style="display: none" id="privilege" value="" name="privilege">
</div>
三、默认值
<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}">
四、checkbox
//多选回显
<div class="row cl">
<input type ="checkbox" name="role"
th:each ="role : ${roleList}"
th:value="${role.roleName}"
th:text ="${role.roleName}"
th:attr ="checked=${userinfo.userRole.contains(role.roleName)?true:false}">
</div>