Is it possible to use both @RequestMapping and @ModelAttribute annotations on the same method in a Spring MVC Controller?
For example I’d like to obtain something like:
@ModelAttribute("export_profiles")
@RequestMapping(value = "/profiles_list", method = RequestMethod.GET)
public @ResponseBody
ExportProfile[] getExportProfilesList() {
edService.getProfiles();
}
I’d like to use this approach because, in my page I have to load a list of ExportProfiles as options into a select. In the same page I can create/delete export profiles, so I have to refresh the profiles list in my select, and I’d like to do this asynchronously using an ajax call to the same metod.
Is it possible to use a single method to set a model attribute and to handle asynchronous requests? Or do I have to use two different methods?
you can just set an attribute of a page like so …