Spring Boot provides a simple way to handle Path Parameters and Query Parameters using @PathVariable
and @RequestParam
.
@PathVariable
)/users/{id}
).@RequestParam
)?
in the URL (e.g., /users?name=Alice
).@RequestParam
.You can use both @PathVariable
and @RequestParam
together.
Set default values "Unknown" if parameter doesn't have city http://localhost:8080/api/user/10/details