What are Spring MVC request mapping annotations?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Spring Boot topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

Spring MVC provides several annotations for mapping HTTP requests to handler methods: @RequestMapping: base annotation — maps requests by URL, method, headers, parameters: @RequestMapping(value = "/users", method = RequestMethod.GET). Can be used at class and method level. Shorthand method-specific annotations: @GetMapping("/users") — HTTP GET; @PostMapping("/users") — HTTP POST; @PutMapping("/users/{id}") — HTTP PUT; @PatchMapping("/users/{id}") — HTTP PATCH; @DeleteMapping("/users/{id}") — HTTP DELETE. Parameter extraction annotations: @PathVariable Long id — extract from URL path: /users/{id}; @RequestParam String name — extract from query string: ?name=Alice (optional with defaultValue); @RequestBody User user — deserialize request body from JSON; @RequestHeader("Authorization") String token — extract from request header; @CookieValue("sessionId") String sessionId. ResponseEntity: wrap return value to control HTTP status, headers, and body: return ResponseEntity.status(201).header("Location", "/users/" + id).body(user);. @ResponseStatus: set default status for a method: @ResponseStatus(HttpStatus.CREATED). Multiple paths: @GetMapping({"/", "/home", "/index"}). Content negotiation: @GetMapping(produces = "application/json"), @PostMapping(consumes = "application/json").

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Spring Boot candidates.