Convert an array object to a json string using JSON.stringify
var array = [1, 2];
let json = JSON.stringify(array);
console.log(json);
axios.get('http://localhost/goods', json).then(function (res) {
if (res.code == 200) {
console.log("ok");
}
}
Parameters during transmission with Chrome browser console:
My goods controller class, for example:
@RequestMapping(value = "goods",method = RequestMethod.GET)
public String deleteByIds(@RequestBody Integer[] ids) {
goodsService.deleteByIds(ids);
return "ok";
}
Spring mvc can't receive an array.Or am I having a problem with writing axios code? How to solve it?
