I' m developing a REST WebApp with spring framework, now i'd like to know the best practice to receive data. It s best to retrieve them with @RequestParam
or @PathVariable
?Obviously i'm interested in receiving simple data like an userid
or an username
.
Using an example:
@RequestMapping(value = "/getdata", method = RequestMethod.GET)
public String GetData(@RequestParam(value = "memberId", required = true) Integer memberId){
//return data for user with Id = memberid;
}
or
@RequestMapping(value = "/getdata/{memberid}", method = RequestMethod.GET)
public String GetData(@pathvariable int memberid){
//return data for user with Id = memberid;
}
I'm interested about REST web services