前端js
var student=new Object();
student.name='tom';
student.age=13;
student.sex='man';
$.post(url, {"studentData":JSON.stringify(student)},
function(data) {
if(data.result == 'success') {
alert( '更新成功!')
});
} else {
alert("更新失败!错误信息:"+data.result);
location.reload();
}
}
);
后端Java
String studentJson=request.getParameter("studentData");
JSONObject JsonObject = new JSONObject().fromObject(studentJson);
Student student = (Student)JSONObject.toBean(JsonObject,Student.class);