JS:
/**接口验证查询按钮*/ function strategyCheckSearch(){ var strategyRows= $("#strategyCheckDg").datagrid('getRows'); var strategyIp = $("#strategyIp").val().trim(); var strategyPort = $("#strategyPort").val().trim(); if(strategyIp.length < 1 || strategyPort.length < 1){ $.messager.alert("错误","请输入IP和端口!",'info'); }else{ $.each(strategyRows,function(i,row){ $.ajax({ url : 'require/getStatusCodeByWget',type : 'post',data : { wgetString : JSON.stringify(row.wget),strategyIp : strategyIp,strategyPort : strategyPort },success : function(data) { var str = ""; $.each(data,result){ console.log(result); if(result.proxyPort == null){//端口值为null则不显示 str += "【"+result.proxyAddress+"】"+result.responses[0].Failed+"<br>"; }else{ str += "【"+result.proxyAddress+":"+result.proxyPort+"】"+result.responses[0].Failed+"<br>"; } }); $("#strategyCheckDg").datagrid('updateRow',{ index:i,row:{ status : str } }); } }); }); } }
Controller:
/**根据wget获取状态码*/ @RequestMapping("getStatusCodeByWget") @ResponseBody public List<WgetResult> getStatusCodeByWget(@RequestParam("wgetString") String wgetString,HttpServletRequest request,@RequestParam("strategyIp") String strategyIp,@RequestParam("strategyPort") String strategyPort) { Wget wget = GsonUtil.toObject(wgetString,Wget.class); String[] ipStrings = strategyIp.split(","); List<String> ipList = Arrays.asList(ipStrings); List<WgetResult> WgetResultList = domainTransferService.validityStrtegy(wget,ipList,strategyPort); return WgetResultList; }要点就是使用$.ajax从后台获取数据之后,在success方法中获取easyui所有行的数据,然后通过$("#").datagrid('updateRow',{});刷新前台数据就可以实现了.