$.ajax方法提交数组参数
springmvc框架
var param = new Object(); var arr = new Array(); arr.push(1,2,3); param.ids=JSON.stringify(arr);
$.ajax({ type:"post", url:"loginInfo/deleteBatch.action", data:param, success:function(){ console.info("删除成功"); } });
后台接收,
注意:参数对象属性名ids,user要和后台接受参数名一致,不然接收不到数据,还不报错
public void deleteBatch(String ids,String user) throws IOException { System.out.println("ids:"+ids);
System.out.println(user); ......
}
打印结果
ids:[1,2,3]
{"name":"hehe","age":22,"gender":"man"}
然后再处理。