I've already seen similar question with no success. I need to send a matrix of numbers from a web app (ReactJS) to a Spring Boot controller.
I've tried many combination but it always get error, my payload is:
{"rows":[[7,0,0,6,4,0,0,0,0],[9,4,0,0,0,0,8,0,0],[0,8,6,2,5,0,0,9,0],[0,0,0,0,6,8,7,3,0],[4,0,8,0,2,1,0,0,0],[0,0,3,0,0,0,1,6,4],[0,0,0,0,0,9,6,7,5],[3,9,0,0,8,5,0,1,2],[0,0,5,0,0,4,0,0,0]]}
My react code is:
axios.post('http://localhost:8090/api/check', {
rows: this.props.rows
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
And my Spring Boot controller is:
@PostMapping(path = "/check")
@CrossOrigin(origins = "http://localhost:3000")
public boolean check(@RequestParam(value = "rows") final int[] array, final int row, final int col, final int num) {
return true;
}
I've already tried to declare @RequestParam(value = "rows[]") or @RequestParam(value = "rows").
Rather than @RequestParam(value = "rows") final Object rows.
But it always respond with error 400 (Bad request).
How can I pass a matrix through POST request?
Thanks
RequestParam? You should pass it inRequestBodyofPOSTrequest instead.axios.post()call? How can I pass it in theRequestBody?