使用將數組對象轉換為 json 字符串 JSON.stringifyvar 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 代碼有問題?如何解決?
1 回答

冉冉說
TA貢獻1877條經驗 獲得超1個贊
根據您的要求,
axios.get('http://localhost/goods', json)
這是一個獲取請求。所以它不會有身體。
您可以嘗試更改 get 方法以發布或使用 @RequestParameter 而不是 @RequestBody。
添加回答
舉報
0/150
提交
取消