select下拉框數據回顯
阿新 • • 發佈:2019-03-04
return urn items 查詢 val servle all div per
前臺頁面
<select class="select" name="operatorId" id="operatorId" style="height: 21px;" > <option value="">所屬運營商</option> <c:forEach items="${operatorList}" var="operator"> <option value="${operator.operatorId}" <c:iftest="${operator.operatorId==operatorId}">selected </c:if> >${operator.operatorName}</option> </c:forEach> </select>
後臺用ModelMap 來回顯到前臺頁面上.
public String advertisingList(HttpServletRequest request, ModelMap model) {//這個map是傳入的值,進行查詢. Map<String, Object> map = new HashMap<>(); String operatorId = request.getParameter("operatorId"); String adClass = request.getParameter("adClass"); String adName = request.getParameter("adName"); map.put("operatorId", operatorId); map.put("adClass", adClass); map.put("adName", adName); //查詢所有廣告位,進行分頁查詢. PageUtil page = this.buildParam(request, map); List<Map<String,Object>> operatorList=operatorService.getAllOperator(); model.put("operatorList", operatorList); List<ChargeAdDTO> chargeAdList = chargeAdService.selectAllChargeAdForPage(map); model.put("chargeAdList", chargeAdList); //前臺數據回顯 model.put("operatorId", operatorId); model.put("adClass", adClass); model.put("adName", adName); model.put("pageBar", page.getToolsMenu()); return "/manage/advertising/advertising_list"; }
靜態數據回顯:
<span class="select-box inline radius" > <select class="select" id="adClass" name="adClass" style="height: 21px;width:100px"> <option value=‘‘ >廣告位類型</option> <option value=‘0‘>圖片輪播</option> <option value=‘1‘>視頻輪播</option> </select> </span>
$(function(){
$("#adClass").find("option[value=‘${adClass}‘]").attr("selected",‘selected‘);
})
文本框的話,直接加上,value="{}"就好了.
<input type="text" class="input-text radius" style="width:150px" placeholder="請輸入廣告位名稱" name="adName" id="adName" value="${adName}">
select下拉框數據回顯