thymeleaf 判断select 下拉框 赋值并选中
下拉框赋值选中:
<div class="form-group"> <label class="col-sm-3 control-label">类别:</label> <div class="col-sm-8"> <select name="category" class="form-control" type="text" id="category" th:field="*{category}"> <option th:value="0" >本省</option> <option th:value="1" >省外资源</option> </select> </div> </div> <div class="col-sm-8"> <select name="teachpoint" class="form-control m-b" th:with="type=${@dict.getType('teach_point')}"> <option></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option> </select> </div>
单选框选中:
<-- aa为值 -->
<input type="radio" name="aa" th:value="0" th:checked="${aa==0}"/>显示
<input type="radio" name="aa" th:value="1" th:checked="${aa==1 }"/>隐藏
<-- aa为对象属性 -->
<input type="radio" name="aa" th:value="0" th:field="*{aa}"/>显示
<input type="radio" name="aa" th:value="1" th:field="*{aa}"/>隐藏
本文原创,转载必追究版权。