What is the real difference between @PostMapping and @PutMapping in Spring?

Viewed 13439

I am trying to update an entity from my Oracle database using a Spring RestController. Whether I use PostMapping or PutMapping on my controller method, the effect is the same on the entity, only the field I want to update gets updated and everything is fine. What is the real difference between the two request methods? Is it only for a clearer description on the controller method?

Update : it seems even if I use a GetMapping, my entity updates correctly. I am really starting to think that the request is getting handled in the Service layer and the request annotation is only for a clearer view on the controller method, but I could be wrong. Really curious for an explanation. Thank you!

Thank you!

1 Answers

I guess you are looking for the Post vs PUT of REST. Check this one.

PUT vs. POST in REST

Even you can do the same operation in the backend for PUT and POST, but there is some routines people are following.

Related