$.ajax方法提交数组参数

springmvc框架

var param = new Object();
var arr = new Array();
arr.push(1,2,3);
param.ids=JSON.stringify(arr);
var user = new Object();
user.name="hehe";
user.age=22;
user.gender="man";
param.user=JSON.stringify(user);

$.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"}

然后再处理。

posted @ 2019-04-16 07:14  AGB  阅读(1611)  评论(0编辑  收藏  举报