samedi 7 mars 2015

Spring: @RequestMapping with multiple values

I don't know this is the right approach but the easiest solution I can come up with in the moment.


I want to use multiple values in @RequestMapping and do the business logic in the method according which value is called the method. Example:



@RequestMapping(value = {"/delete", "/save"}, method = RequestMethod.POST)
public String crudOps(@ModelAttribute ("userForm") User user) {

// find user in repository....

if(value is delete)
delete(user);
else
save(user);
}


How can I make that if statement work?


Aucun commentaire:

Enregistrer un commentaire