Abhimanyu Mishra’s Post

When building APIs in Spring Boot, you’ll see multiple mapping annotations. But what’s the difference? @RequestMapping → Generic mapping (can handle all HTTP methods) @GetMapping → Used for GET requests (fetch data) @PostMapping → Used for POST requests (create data) Example: @RestController @RequestMapping("/users") public class UserController { @GetMapping public List<String> getUsers() { return List.of("A", "B"); } @PostMapping public String createUser() { return "User created"; } } Modern Spring Boot prefers specific annotations like @GetMapping for clarity. Rule of thumb: GET → Read POST → Create PUT → Update DELETE → Remove Next post: What is @PathVariable and @RequestParam #Java #SpringBoot #APIDevelopment #BackendDevelopment

To view or add a comment, sign in

Explore content categories