While working on a #SpringMVC feature, I was reminded how much clarity comes from choosing the right annotation:
@PathVariable vs @RequestParam
If the value identifies which resource you’re accessing -> @PathVariable
If the value refines how you query it -> @RequestParam
Example:
/rooms/42 -> room 42
/rooms?date=2025-01-15 -> rooms filtered by date
The code works either way, but the API tells a clearer story when the intent is right.