java - Multiple @RequestMapping (value, method pairs) in Spring MVC -
i achieve spring mvc
@requestmapping(value = "/user/{userid}", method = requestmethod.delete) @requestmapping(value = "/user/{userid}/delete", method = requestmethod.post) public void deleteuser(@pathvariable string userid) { ... }
this give me common endpoint rest calls , standard html form posts. possible spring mvc? can come is
@requestmapping(value = { "/user/{userid}", "/user/{userid}/delete"}, method = {requestmethod.delete, requestmethod.post}) public void deleteuser(@pathvariable string userid) { ... }
but result different because post "/user/{userid}" delete user.
one thing make 2 separate methods own requestmapping
annotation, , pass parameters on different method, actual stuff:
@requestmapping(value = "/user/{userid}/delete", method = requestmethod.post) public void deleteuserpost(@pathvariable string userid) { deleteuser(userid); } @requestmapping(value = "/user/{userid}", method = requestmethod.delete) public void deleteuserdelete(@pathvariable string userid) { deleteuser(userid); } private void deleteuser(string userid){ //do things here }
Comments
Post a Comment