This should work:
@RequestMapping(method = RequestMethod.POST, value = "personDetails.html")
public @ResponseBody Result math(@RequestBody List<Persons> personList) { ... }
- UNITED AND ADDED EXAMPLE -
I tested this locally and it works for me. Here's the code snippet:
public class TestController {
public static class Test {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@RequestMapping(value = "/debug/test1.json", method = RequestMethod.POST)
@ResponseBody
public Test[] testList1(@RequestBody Test[] test) {
return test;
}
@RequestMapping(value = "/debug/test2.json", method = RequestMethod.POST)
@ResponseBody
public List<Test> testList2(@RequestBody List<Test> test) {
return test;
}
}
Here are the test results (I tested it with curl):
Request:
curl --header "Content-type: application/json" --header "Accept: application/json" --data '[{"name": "John"}, {"name": "Jack"}]' http://localhost:8080/app/debug/test1.json
Response:
[{"name":"John"},{"name":"Jack"}]
Request:
curl --header "Content-type: application/json" --header "Accept: application/json" --data '[{"name": "John"}, {"name": "Jack"}]' http://localhost:8080/app/debug/test2.json
Response:
[{"name":"John"},{"name":"Jack"}]
PS. - spring MVC, JSON , . , spring MVC . log4j.properties, , JSON :
log4j.logger.org.springframework.web.servlet.mvc.method.annotation=TRACE