I'm developing Spring Rest webs service using PUT and POST
@RequestMapping(value = "/test", method = RequestMethod.POST)
@Override
public String function(Model model)
{
}
So, what is the difference between using PUT and POST in this case?
I know that PUT is idempotent, meaning if the same url is called multiple times, the effect should be the same. If I provide the request method as PUT and if I include a DB operation inside the function, won't the meaning of PUT change, meaning if I call the test url multiple times, the DB value will change each time.
My question is does the idempotence, state change, all those features depend on the developer's implementation?
Better example:
@RequestMapping(value = "/test", method=RequestMethod.POST, produces={"application/json"})
public @ResponseBody List<Integer> postData(@RequestParam String name) {
if (name.equalsIgnoreCase("okkk")) {
return returnDataList();
}else {
List<Integer> list = new ArrayList<Integer>();
list.add(12345);
return list;
}
}
@RequestMapping(value = "/test/{name}", method=RequestMethod.PUT, produces={"application/json"})
public @ResponseBody List<Integer> putData(@PathVariable String name) {
if (name.equalsIgnoreCase("okkk")) {
return returnDataList();
}else {
List<Integer> list = new ArrayList<Integer>();
list.add(12345);
return list;
}
Both the methods are the same, I believe. I just put PUT and POST, a little confused.