Abhimanyu Mishra’s Post

When working with APIs, you often need to pass data in the request. Spring Boot provides two common ways: @PathVariable and @RequestParam Example: @GetMapping("/users/{id}") public String getUser(@PathVariable int id) { return "User ID: " + id; } Here, id is part of the URL. Now using RequestParam: @GetMapping("/users") public String getUser(@RequestParam int id) { return "User ID: " + id; } Difference: • @PathVariable → part of URL path • @RequestParam → query parameter Example URLs: /users/10 → PathVariable /users?id=10 → RequestParam Choosing the right one improves API design. Next post: What is @RequestBody and how JSON is handled #Java #SpringBoot #BackendDevelopment #APIDesign

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories