使用将数组对象转换为 json 字符串 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");
}
}
使用 Chrome 浏览器控制台传输时的参数:
我的商品控制器类,例如:
@RequestMapping(value = "goods",method = RequestMethod.GET)
public String deleteByIds(@RequestBody Integer[] ids) {
goodsService.deleteByIds(ids);
return "ok";
}
Spring mvc 无法接收数组。还是我写 axios 代码有问题?如何解决?
冉冉说
相关分类