在方法的形参那可以用多个@RequestBody来把json字符串封装成多个对象么?用一个@RequestBody.肯定可以,多个这个注解可以封装多个不同的对象么……
迷茫2017-04-18 10:57:14
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...