假设,如果我有这样的JSON
数据,
var json = {"name":"kite Player","age":"25","hobby":"footbal"}
我可以发送JSON
数据
var jsonData = JSON.Stringfy(json);
在JQueryAjax
,
data = jsonData ,
我可以通过以下方式解析spring控制器中的JSON数据,
public class TestController {
@RequestMapping(method = RequestMethod.POST, value = "personDetails.html")
public @ResponseBody Result math(@RequestBody final Persons persons) {
String name = person.getName();
String age = persons.getAge();
String hobby = persons.getHobby();
// Other process
}
}
如果我需要发送多个人的详细信息,我JSON
该如何解析,Spring controller
JSON
var json = [ {"name":"kite Player","age":"25","hobby":"footbal"},
{"name":"Steve","age":"40","hobby":"fishing"},
{"name":"Marker","age":"28","hobby":"cricket"}
]
希望我们的堆栈成员能给出一个好的解决方案。