当ajax 向spring mvc传递复杂数据时,
1.利用 jackson
@JsonProperty("XXX")标注复杂类型
2.后台需要用
@RequestBody Object object
承接
3.前台传递数据
需要字符转义JSON.stringify(this.data)
需要加上 contentType: 'application/json'
let data = JSON.stringify(this.data);
console.log(data)
$.ajax({
url: Feng.ctxPath + "/XXX/add",
type: "POST",
data: data,
dataType: "json",
contentType: 'application/json',
cache: false,
success: function(data) {
Feng.success("添加成功!");
},
error:function (e) {
Feng.error("添加失败!" + data.responseJSON.message + "!");
}
});否则后台接NULL