ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
js传递数组必须用$.ajax(),不能使用$.post() 方法一: 1.使用JSON.stringify 将数组对象转化成json字符串; ``` var array = ["1", "2"]; $.ajax({ type : 'POST', url: path + '/check/testPost', contentType : "application/json" , data : JSON.stringify(array), success : function(data) { } }); ``` 传输过程中参数 ![](https://img.kancloud.cn/28/3e/283e6938bef88921b37421561f925d24_552x143.png) 方法二: 1.前端不做处理: ``` var array = ["1", "2"]; $.ajax({ type : 'POST', url: path + '/check/testPost', contentType: "application/x-www-form-urlencoded", data: {"array": array}, success : function(data) { } }); ``` 传输过程中参数 ![](https://img.kancloud.cn/4e/98/4e98a01ced47d41577de992993257268_488x94.png) **注:两种post请求的content-type不同**