@RequestMapping accepts several attributes that together define exactly which requests a handler matches, going beyond just the URL. Understanding these attributes explains how Spring narrows down which method should process a given request.
@RequestMapping(value = "/orders", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") only matches POST requests to /orders that send and expect JSON.
@RequestMapping(
value = "/orders",
method = RequestMethod.POST,
consumes = "application/json",
produces = "application/json"
)
public Order createOrder(@RequestBody Order order) { ... }A concise interview answer is
@RequestMapping supports value or path for the URL, method for the HTTP verb, and consumes/produces to restrict matching by content type. It also has params and headers for finer-grained matching, and name to give the mapping a reusable identifier.
Last updated: 16 July 2026
Previous question: How can you define method-level request mappings in a Spring MVC controller?
Next question: How does @RequestMapping handle different types of HTTP requests?