Ajax之Json对象序列化传参
Posted long77
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ajax之Json对象序列化传参相关的知识,希望对你有一定的参考价值。
前端部分:传入参数 "groupObject" : jsonString
//对象序列化传参
var projectGroup = {};
projectGroup["id"] = id;
projectGroup["isEnable"] = isEnable;
projectGroup["employeeNo"] = employeeNo;
projectGroup["employeeName"] = employeeName;
projectGroup["centerName"] = centerName;
projectGroup["deptName"] = deptName;
projectGroup["projectInfoNo"] = projectInfoNo;
projectGroup["centerId"] = centerId;
projectGroup["deptId"] = deptId;
projectGroup["employeeImg"] = employeeImg;
var jsonString = JSON.stringify(projectGroup);
后端部分:接收参数 String groupObject;
// json串转指定bean
projectGroup projectGroup2 = null;
try {
projectGroup2 = new ObjectMapper().readValue(groupObject, projectGroup.class);
} catch (IOException e) {
e.printStackTrace();
}
以上是关于Ajax之Json对象序列化传参的主要内容,如果未能解决你的问题,请参考以下文章
spring mvc接收ajax提交的JSON数据,并反序列化为对象