bean 類型 以下java
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 ;
}
});ajax後臺代碼:json
public String f1( @RequestBody User u,app
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 ;
}
});asyncpublic String f2( User u,post
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;
}this