1. 程式人生 > >ajax傳陣列到後臺,後臺springmvc 接受陣列引數

ajax傳陣列到後臺,後臺springmvc 接受陣列引數

關於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";  }