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=${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>

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 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>

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="${role.roleName}"
		th:text ="${role.roleName}"
		th:attr ="checked=${userinfo.userRole.contains(role.roleName)?true:false}">
</div>

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值