springMVC接受数组
var obj = {}; var params = new Array(); var selected1 = $('#datatable').DataTable().rows('.selected').data(); for (var i=0;i<selected1.length;i++){ params.push(selected1[i].id); } obj.dataid = params; $.ajax({ type : "POST", url: '${rc.contextPath}/xx/xxx', contentType : 'application/json', data: JSON.stringify(obj), success : function(msg) { swal( "删除成功!", "", "success" ); $("#deleteModal").modal('hide'); $('#datatable').DataTable().ajax.reload(); },error:function(){ swal( "删除失败!", "", "error" ); } })
@RequestMapping("") @ResponseBody public ResultObject delDatas(HttpServletRequest request,HttpServletResponse response, @RequestBody JSONObject params){ JSONArray idArray = params.getJSONArray("dataid"); List<String> ids = idArray.toJavaList(String.class); return new ResultObject(); }