问题 
我实现了一个 Spring RESTful Web 服务。使用 Jackson JSON 的对象映射。我有一个接受两个参数的方法。 
- public Person createPerson(
 
 -     @RequestBody UserContext userContext,
 
 -     @RequestBody Person person)
 
  复制代码 
客户端如何构造一个请求,其中将在正文中传递多个 JSON 对象? 
 
是否可以? 
 
 - 斯里兰卡 
 
回答 
我很确定这行不通。可能有一种解决方法,但更简单的方法是引入包装对象并更改您的签名: 
- public class PersonContext{
 
 -     private UserContext userContext;
 
 -     private Person person;
 
 -     // getters and setters
 
 - }
 
  
 
- public Person createPerson(@RequestBody PersonContext personContext)
 
  复制代码 
 
 
 
 |