Performance: Request mapping by method and path
MEDIUM IMPACT
This affects server response routing speed and how quickly the server matches incoming requests to handlers.
@GetMapping(path = "/api/data") public String handleGet() { return "get response"; } @PostMapping(path = "/api/data") public String handlePost() { return "post response"; }
@RequestMapping(path = "/api/data") public String handleAllRequests(HttpServletRequest request) { // handle GET, POST, PUT, DELETE all here String method = request.getMethod(); // logic to handle different methods return "response"; }
| Pattern | Routing Complexity | Method Checks | Response Time Impact | Verdict |
|---|---|---|---|---|
| Generic @RequestMapping for all methods | High - checks method at runtime | Multiple per request | Slightly higher latency | [X] Bad |
| Specific @GetMapping, @PostMapping per path | Low - direct mapping | Single per request | Lower latency | [OK] Good |