淘先锋技术网

首页 1 2 3 4 5 6 7

关于ajax传数组到后台,后台springmvc  接受数组参数  特意整理了一下】

 

 

var   ids= new Array();
 var checkId = new Array();//定义一个数组用来接收参数
        $("input:checked").each(function() {
            checkId.push($(this).val());
        });
  
  $.ajax({
   url : ctx + "/test/setNoProcess.do",
   type : "get",
   data :{ids:ids},
   success : function(data) {
    if ($.trim(data)=="success") {
      showTip("处理成功!");
     }else{
      showTip("处理失败!");
     }
   }
  });

后台springmvc 接收:

@RequestMapping("/test/setNoProcess")
 @ResponseBody
 public String setNoProcess(@RequestParam(value = "ids[]")  Integer[]  ids){
  
   List<Integer>   list= Arrays.asList(ids);
  
  try{
   decDeliverOrderService.getMapper().statusBatchUpdateToInit(list);
  }catch(Exception e){
   log.error(e);
   return  "error";
  }
  return  "success";
 }