$("#test2").on("click",function(){
var id =1
var username="fangxin"
$.post("/mvc/client1/test2",{id:id,username:username,birthday:new Date()})
});
Spring后台接收
@RequestMapping("/test2")
@ResponseBody
public void test2(User user){
System.out.println(user.getId())
System.out.println(user.getUsername())
System.out.println(user.getBirthday())
}
我以前是这么做的:var codes=[1,2,3]//定义数组
$.ajax({
type: "POST", //用POST方式传输
dataType: "json", //数据格式:JSON
url: ..., //目标地址
traditional: true,
data: {
codes:codes,
},
error: function (XMLHttpRequest, textStatus, errorThrown) {...},
success: function (msg){...}
})
注意traditional: true不能少,
for(int m=0m<codes.lengthm++){
String code=codes[m]
...
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)