thymeleaf单选回显,多选回显,下拉选回显,默认选中第一个

thymeleaf单选回显,多选回显,下拉选回显,默认选中第一个

//默认选中第一个
<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}">
//单选回显
<input type="radio" name="repaymentType"
   th:each ="repaymentType:${repaymentTypeList}"
   th:value="${repaymentType.dictName}"
   th:text ="${repaymentType.dictName}"
   th:attr ="checked=${financeProductDO.repaymentType == repaymentType.dictName?true:false}">
//多选回显
<input type ="checkbox" name="companyRole"
	th:each ="role : ${companyRoleList}"
	th:value="${role.dictName}"
	th:text ="${role.dictName}"
	th:attr ="checked=${companyInformation.companyRole.contains(role.dictName)?true:false}">
//下拉选回显默认选中 前台接收到参数:user对象和businessList集合
<option th:selected="${user.businessId eq busi.businessId}"
		th:each="busi:${businessList}"
		th:value="${busi.businessId}"
		th:text="${busi.businessName}" >
</option>

猜你喜欢

转载自blog.csdn.net/qq_43639296/article/details/83895982
今日推荐