项目中简单的编辑 需要回显下拉框数据,用来记录学习过程
静态数据回显(下拉框只有,口服和针剂两种)
<select data-placeholder="请设置类型" name="medicineType" id="medicineType"
class="form-control" th:value="${product.medicineType}">
<option th:selected="${product.medicineType=='口服'}" value='口服'>口服</option>
<option th:selected="${product.medicineType=='针剂'}" value='针剂'>针剂</option>
</select>
动态回显 (数据库获取 ,后台model 返回product)
<select id="enterpriseCode" name="enterpriseCode"
required lay-verify="required" class="form-control">
<option
th:selected="${product.enterpriseCode eq p.enterpriseCode}"
th:each="p : ${product}"
th:value="${p.enterpriseCode}"
th:text="${p.enterpriseName}"></option>
</select>