In fact, there is always one request parameter, because a request only contains one request body. If you understand this, you will understand that Spring MVC does not support multiple @RequestBody.
As for deserializing the content in a request body into several Java instances, it is another problem. There are three solution directions:
Create a new entity and put your two entities in it. This is the simplest, but not "elegant" enough.
Use Map<String, Object> to accept the request body and deserialize it into each entity yourself.
Similar to method 2, but more generic, implement your own HandlerMethodArgumentResolver. Please refer to: https://sdqali.in/blog/2016/0...
In fact, there is always one request parameter, because a request only contains one request body. If you understand this, you will understand that Spring MVC does not support multiple @RequestBody.
As for deserializing the content in a request body into several Java instances, it is another problem.
There are three solution directions:
Create a new entity and put your two entities in it. This is the simplest, but not "elegant" enough.
Use Map<String, Object> to accept the request body and deserialize it into each entity yourself.
Similar to method 2, but more generic, implement your own HandlerMethodArgumentResolver. Please refer to: https://sdqali.in/blog/2016/0...
Let’s list a business scenario