前端
axios.post("/getByUserIds",
qs.stringify(
{"userIds": userIds}, //userIds=["1","2","3"]
{indices: false}) //该参数控制影响后台接收,参数传递格式(userIds=1&userIds=2&userIds=3)
).then(
function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
后端
@RequestMapping(value = "/validBatchUploadSettleCertificate", method = RequestMethod.POST)
public Result getByUserIds(@RequestParam("userIds") String[] userIds) {
System.out.println(userIds);
}
qs.stringify indices格式
qs.stringify({userIds: [1, 2, 3]}, { indices: false })
//形式: userIds=1&userIds=2&userIds=3
qs.stringify({userIds: [1, 2, 3]}, {arrayFormat: ‘indices‘})
//形式: userIds[0]=1&userIds[1]=2&userIds[2]=3
qs.stringify({userIds: [1, 2, 3]}, {arrayFormat: ‘brackets‘})
//形式:userIds[]=1&userIds[]=2&userIds[]=3
qs.stringify({userIds: [1, 2, 3]}, {arrayFormat: ‘repeat‘})
//形式: userIds=1&userIds=2&userIds=3