@RequestMapping(value="mno/{objectKey}", method = RequestMethod. GET, consumes="application/json") public List<Book> getBook4(@RequestParam ObjectKey objectKey) { ... } @RequestMapping(value="ghi/{objectKey}",method = RequestMethod. GET) public List<Book> getBook2(@PathVariable ObjectKey objectKey) { ... }
If you don't add @RequestBody it will insert null values (should use), no need to use @ResponseBody since it's part of @RestController.
Simply put, the @RequestBody annotation maps the HttpRequest body to a transfer or domain object, enabling automatic deserialization of the inbound HttpRequest body onto a Java object. Spring automatically deserializes the JSON into a Java type, assuming an appropriate one is specified.
I'm pretty sure that won't work. There may be a workaround, but the much easier way would be to introduce a wrapper Object and change your signature:
public class PersonContext{
private UserContext userContext;
private Person person;
// getters and setters
}
public Person createPerson(@RequestBody PersonContext personContext)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With