I have an endpoint declared like this
@GetMapping("/shoebox")
public ResponseEntity<?> find(ShoeBox shoebox) {
...
}
When I make a request like /shoebox?color=blue&size=small
It correctly binds color
and size
to a new ShoeBox
object.
But if I delcare with @RequestParam
like this
@GetMapping("/shoebox")
public ResponseEntity<?> find(@RequestParam ShoeBox shoebox) {
...
}
Then I get this error
{
"status": 400,
"message": "Required request parameter 'shoebox' for method parameter type ShoeBoxis not present",
"timestamp": 1621373682288,
"errors": [
"MissingServletRequestParameterException"
]
}
I understand a little of why it doesn't work with @RequestParam
because I'm not using a single param, but what I don't understand is why it works without any annotation at all. How does it know to bind it? Is this functionality documented anywhere?