Java spring控制器json接收json列表

Java spring控制器json接收json列表,java,json,spring,rest,jackson,Java,Json,Spring,Rest,Jackson,我确实在下面发了一篇文章 {"testListObject":[{"testText":"bbb","testDate":"02.01.2011 00:00:00.000"},{"testText":"aaa","testDate":"01.01.2011 00:00:00.000"}]} 在我的spring控制器中,我有 @RequestMapping(value = "/post/tester/", method = RequestMethod.POST) public @Respons

我确实在下面发了一篇文章

{"testListObject":[{"testText":"bbb","testDate":"02.01.2011 00:00:00.000"},{"testText":"aaa","testDate":"01.01.2011 00:00:00.000"}]}
在我的spring控制器中,我有

@RequestMapping(value = "/post/tester/", method = RequestMethod.POST)
 public @ResponseBody String postItinerary(@ModelAttribute("testListObject") TestList testList) throws IOException {


    System.out.println("1="+testList); //ok
    System.out.println("2="+testList.childListObject); //print null
}
知道为什么列表childListObject的值为null吗

我的pojo如下所示

    public class TestList (){

    public List<ChildObject> childListObject;

//get and set
    }


    public class ChildObject(){

    public String testText;
    public String testDate;
//get and set    
}
公共类测试列表(){
公共列表childListObject;
//出发
}
公共类ChildObject(){
公共字符串testText;
公共字符串testDate;
//出发
}

您是否在设置xml中配置了org.springframework.http.converter.json.MappingJacksonHttpMessageConverter?

@modeldattribute
调用web数据绑定器。它正在寻找普通的post方法参数(例如,param key—“childListObject[0].testText“param value”bbb”)绑定到您的对象上。
要将JSON反序列化为对象,您需要使用
@RequestBody
调用序列化程序

此外,您的JSON似乎与obect不匹配。JSON只是一个没有包装器对象的数组,因此如果您将其作为请求提交,那么方法参数将只是一个列表