0

I am trying to write a REST PUT method and I am not sure how you get the body that the requestor is sending. For example, he is going to send a Person object serialized to JSON and I want to serialize the JSON back to a Person object.

I couldn't find much on Spring PUT, but here is what I have:

@RequestMapping(method = RequestMethod.PUT)
    public Person registerPerson(@PathVariable String siteId, @ModelAttribute("personForm") Person user) throws Exception {

        //some Logic

    }

I don't think I am doing this correctly. Does @ModelAttribute automatically serialize?

Alan
  • 9,331
  • 14
  • 52
  • 97

1 Answers1

0

Try this :

@RequestMapping(method = RequestMethod.PUT)
    public Person registerPerson(@RequestBody Person user) throws Exception {

        //some Logic

    }
Pracede
  • 4,226
  • 16
  • 65
  • 110