@RequestMapping annotation in Spring Boot?@RequestMapping is used to map web requests to specific handler classes or methods in Spring Boot. It defines the URL path and HTTP method that a controller or method will respond to.
How does <code>@RequestMapping</code> work when placed on a class level?When @RequestMapping is placed on a class, it sets a base path for all the methods inside that class. Each method's path is appended to this base path.
Example: What URL will the method respond to if the class has <code>@RequestMapping("/api")</code> and the method has <code>@RequestMapping("/users")</code>?The method will respond to requests at /api/users. The class-level path /api is combined with the method-level path /users.
@RequestMapping specify HTTP methods? How?Yes. You can specify HTTP methods like GET, POST, etc., using the method attribute, for example: @RequestMapping(value = "/path", method = RequestMethod.GET).
What happens if you omit the path in <code>@RequestMapping</code> at the class level?<p>If omitted, the class does not set a base path, so method-level paths are treated as absolute from the root context.</p>@RequestMapping("/app") on a class do?Class-level @RequestMapping sets a base path for all methods inside the class.
@RequestMapping("/list") and the class has @RequestMapping("/api"), what is the full path?The method path is appended to the class base path, resulting in /api/list.
@RequestMapping?Use method = RequestMethod.POST inside @RequestMapping to specify POST requests.
@RequestMapping is on the class but methods have paths?Without a class-level path, method paths are absolute from the root.
@RequestMapping with GET method?@GetMapping is a shortcut for @RequestMapping(method = RequestMethod.GET).
@RequestMapping at the class level affects the URL paths of methods inside the class.@RequestMapping.