So I have a little issue here as described. In the following first example I'm passing a simple array which is working. If I want to pass an array of arrays in the second example, it isn't working anymore. Any suggestions?
This works:
JS
var myArrayOfStrings = ["x", "y"];
function createConsumer(){
$.ajax({
type: "POST",
url: "/save",
data: { myArray: myArrayOfStrings }
});
}
Controller
@RequestMapping(value = "/save", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void Submit(@RequestParam("myArray[]") String[] name) {
System.out.println(name[0]);
}
The following solution isn't working, why? I just want to pass an Array of Arrays instead of a "simple Array". How will it work?
JS
var myArrayOfArrays = [["x", "y"],["x", "y"]];
function createConsumer(){
$.ajax({
type: "POST",
url: "/save",
data: { myArray: myArrayOfArrays }
});
}
Controller
@RequestMapping(value = "/save", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void Submit(@RequestParam("myArray[][]") String[][] name) {
System.out.println(name[0][0]);
}