Performance: @RequestMapping for base paths
MEDIUM IMPACT
This affects the routing and request handling speed in Spring Boot applications, impacting how quickly the server matches incoming requests to controllers.
@RestController @RequestMapping("/api") public class MyController { @RequestMapping("/users") public String getUsers() { return "users"; } @RequestMapping("/products") public String getProducts() { return "products"; } }
@RestController @RequestMapping("/") public class MyController { @RequestMapping("users") public String getUsers() { return "users"; } @RequestMapping("products") public String getProducts() { return "products"; } }
| Pattern | Route Checks | CPU Overhead | Response Time Impact | Verdict |
|---|---|---|---|---|
| Broad base path '/' | High (checks many routes) | High | Slower response | [X] Bad |
| Specific base path '/api' | Low (checks fewer routes) | Low | Faster response | [OK] Good |