思路:①将选中的下拉框的信息的ID传给后台,然后在后台放到request域中
②在前台接收下拉框信息的同时一并接收选中信息,在遍历的同时进行<c:if>判断,若匹配则selected
具体代码:
1、在handler中,将选中的信息放在request中
mv.addObject("cust_source", customer.getCust_source());
mv.addObject("cust_industry", customer.getCust_industry());
mv.addObject("cust_level", customer.getCust_level());
2、在前台中进行遍历判断
<select class="form-control" id="customerFrom" name="cust_source">
<option value="">--请选择--</option>
<c:forEach items="${source }" var="dict">
<c:if test="${dict.dict_id == cust_source}">
<option value="${dict.dict_id }" selected>${dict.dict_item_name }</option>
</c:if>
<c:if test="${dict.dict_id != cust_source}">
<option value="${dict.dict_id }">${dict.dict_item_name }</option>
</c:if>
</c:forEach>
</select>
完美解决查询后下拉框没选中的问题