后端根据条件查询返回List
@RequestMapping("/findGatewayNumList")
@ResponseBody
public Map<String, Object> findGatewayNumList(DevicePage devicePage,
HttpServletRequest request) {
Map<String, Object> map = new HashMap<String, Object>();
try {
List<DevicePage> devicePageList= deviceService.findDevicePageList2(devicePage);
if (null != devicePageList) {
map.put("device", devicePageList);
} else {
map.put("success", false);
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
前端解析
$.ajax({
type : 'post',
url : basePath + 'DeviceController/findGatewayNumList.do',
data : {
'buildId' : buildId,
},
dataType : 'json',
success : function(msg) {
var res = eval("(" + msg + ")");
var netList = res.device;
$.each(netList, function (i, item) {
jQuery("#buildId").append("<option value="+item.gatewayId+">"+item.gatewayNum+"</option>");
});
},
error : function() {
}
})
<select id="buildId" name="buildId" class="common-text" style="width: 150px;" >
</select>