Member-only story
Chapter 19: Spring Boot PUT REST API — @PutMapping Annotation
Previous Chapter:
Introduction
In this chapter, we will cover the @PutMapping
annotation in Spring Boot. The @PutMapping
annotation is used to handle HTTP PUT requests, which are typically used to update existing resources. We will create endpoints to update resources using this annotation, focusing on the Employee entity as our primary example.
Understanding @PutMapping Annotation
What is @PutMapping?
The @PutMapping
annotation in Spring Boot is used to map HTTP PUT requests to specific handler methods in a controller.
It is a specialized version of the @RequestMapping
annotation designed specifically for handling PUT requests, which are usually used for updating existing resources.
How @PutMapping Works
When a client sends an HTTP PUT request to a specified URL, the @PutMapping
annotation maps this request to a specific handler method in the controller. The method processes the request, typically updating a resource on the server, and returns a response.