Transform an array data structure into a JSON string by utilizing JSON.stringify
var nums = [3, 5];
let jsonNums = JSON.stringify(nums);
console.log(jsonNums);
axios.get('http://localhost/items', jsonNums).then(function (response) {
if (response.code == 200) {
console.log("Success");
}
}
Observing parameters in transit through the Chrome browser console:
https://i.sstatic.net/V0LE9.png
An example of my items controller class:
@RequestMapping(value = "items", method = RequestMethod.GET)
public String removeByIds(@RequestBody Integer[] idList) {
itemService.removeByIds(idList);
return "ok";
}
Spring MVC seems to have difficulty processing arrays. Could this be an issue with how I've written the axios code? Any suggestions on how to resolve this?