2019独角兽企业重金招聘Python工程师标准>>>
bean 类型 如下
1. json 字符串
$.ajax({
url :'${ctx}/test/testData/f1?book=java',
type: 'post',
dataType : "json",
contentType:'application/json;charset=UTF-8',//关键是要加上这行
data : JSON.stringify( {id:'22',remarks:'aaa',father:{id:'333',remarks:'bbb'}}),
async : false, // 同步请求
success : function(data) {
debugger ;
}
});后台代码:
public String f1( @RequestBody User u,
2.json 对象
$.ajax({
url :'${ctx}/test/testData/f2?book=java',
type: 'post',
dataType : "json",
data : {id:'22',remarks:'aaa','father.id':'333','father.remarks':'bbb'},
async : false, // 同步请求
success : function(data) {
debugger ;
}
});public String f2( User u,
private static final long serialVersionUID = 1L;
private String id;
private String remarks;
private User father;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public User getFather() {
return father;
}
public void setFather(User father) {
this.father = father;
}