beginnerBuilding REST APIs
What's the difference between `@RequestBody` and `@RequestParam`?
`@RequestBody` deserializes the entire HTTP request body (typically JSON) into a Java object via Jackson, used for POST/PUT payloads. `@RequestParam` reads a single named value from the URL query string or form data, used for simple scalar inputs like `?page=2`. Mixing them up — expecting a `@RequestParam` when the client actually sent a JSON body — is a common source of 400 errors.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response