I am working on a Spring-MVC application in which I want to send different types of java.util.List to the AJAX method. I don't know if we can use model.addAttribute in the controller when giving data to AJAX method.
Situation is :
@RequestMapping(value=/mappingurl)
public @ResponseBody void sendDataToAjax(){
List<Item1> item1;
List<Item2> item2;
List<Item3> item3;
model.addAttribute("item1collection",item1);
model.addAttribute("item2collection",item2);
model.addAttribute("item3collection",item3);
}
Will this work when it is an AJAX method, if not, what can I do so I can send List of objects and access it inside AJAX method. I hope my question is clear, if not, please let me know, I will improvise. Thanks. :-)
return(a JSON for instance) and should be able to parse/consume it in the client side when the AJAX call finalizes