ajax的post请求多同名参数数处理

先说一下问题的发生场景
后台接收

参数 参数说明
token 字符串
person 对象
Person 对象说明
name 姓名,String
age 年龄,Integer
ids 集合,List

针对这种情况一般是吧token放在Person里面后台@RequestBody接受,
先在不想使用json接收,现在写法如下

$.ajax({
		type:"post",
		url:url,
		//contentType: "application/json",
		data:{"token":"db18fbc6-6492-4b6a-9f29-1d84fd70c92e",
		"ids":[86,77] ,

			"name":"测试2222",
			"age":1},
		traditional :true,//这是关键阻止jquery深度序列化
		success:function(r){
			console.log("哈哈");
		console.log(r);
		}
	
	})

后台接收在这里插入图片描述
问题解决。

本文为原创作品,转载请注明出处

发布了42 篇原创文章 · 获赞 13 · 访问量 8326

猜你喜欢

转载自blog.csdn.net/weixin_43328357/article/details/90607198