Cant pass array to java spring controller

Viewed 29

I am trying to store a name of a image, and 2 drop down values into a String array and then pass it as a array to my controller in spring.It works with json and string but never an array yet

@PostMapping(value = "/saveData")
    public ModelAndView save(@RequestBody String choices,@ModelAttribute Data data,Model model){
        System.out.println(choices.toString());


EDIT:
Its in json just so I could test that values were coming in. Now I just need them 2 be an array

js

$.ajax(url, {
    data: JSON.stringify(choices2),
    datatype : "application/String[]",
    contentType: "text/plain",
    type: 'POST'
});
0 Answers
Related