@GetMapping: This annotation is used to map HTTP GET requests onto specific handler methods in Spring MVC controllers. It is used to handle GET requests for a specific URI (Uniform Resource Identifier).
it is like saying "When someone wants to view some information (like a list of books), use this method to get that information and show it to them." It's for retrieving data.
@PostMapping: This annotation is used to map HTTP POST requests onto specific handler methods in Spring MVC controllers. It is used to handle POST requests for a specific URI.
This one is for sending data to the server to create something new. Imagine you're adding a new book to a library. When you fill out a form online and hit "submit," that's a POST request. This annotation tells Spring Boot to use a specific method to handle creating new data.
@PutMapping: This annotation is used to map HTTP PUT requests onto specific handler methods in Spring MVC controllers. It is used to handle PUT requests for a specific URI.
it is used for updating existing data. Let's say you want to change the details of a book in the library's database. You'd use a PUT request to send the updated information to the server. This annotation tells Spring Boot which method to use to update that data.
@DeleteMapping: This annotation is used to map HTTP DELETE requests onto specific handler methods in Spring MVC controllers. It is used to handle DELETE requests for a specific URI.
this one is for deleting data. If you want to remove a book from the library's database, you'd send a DELETE request. This annotation directs Spring Boot to use a specific method to handle deleting that data.
summary:@GetMapping: Retrieve data.
@PostMapping: Create new data.
@PutMapping: Update existing data.
@DeleteMapping: Delete data.
Comments
Post a Comment