I am a newbie in Spring MVC. Below is my post method handler code block.
@RequestMapping(value = "/fruit", method = RequestMethod.POST, produces = {"application/json"})
public void newFruitVideo(
@RequestParam String catalog
) {
String result = "";
JSONObject catalogJson = JSONObject.parseObject(catalog);
}
I can get the request param from annotation RequestParam even though the client send the request with param filled in request body. Why?
Below is my put method handler code block.
@RequestMapping(value = "/fruit/{id}", method = RequestMethod.PUT, produces = {"application/json"})
public void editFruitVideo(
@PathVariable Long id,
@RequestParam String catalog
) {
String result = "";
JSONObject catalogJson = JSONObject.parseObject(catalog);
}
When I do the same thing like the post, a 405 "PUT method is not supported" is returned. When I change to use RequestBody, it works. Why?