8

I know that we can map an object using _method(@RequestBody ObjectClass obj).

What i'm trying to achieve is _method(@RequestBody ObjectClass obj, @RequestBody OtherObjectClass obj2) but doesn't work.

Is there some way to map two objects using same request?

Thanks!

Pedro Silva
  • 460
  • 2
  • 4
  • 16

1 Answers1

5

A HTTP request is made up of headers and body. For a single request, you have a single request body, you can't have two. You can then parse the request body to extract different variables from it, for example if your request body is a JSON, then you can parse it and convert it into an object.

See this example, further on at section "Passing multiple json objects"

evilpenguin
  • 5,448
  • 6
  • 41
  • 49