这是我的Controller方法:
@RequestMapping( value={"/home"},params="userAction=loadHomePage",method=Request.POST)
public String viewPage(@ModelAttribute("dataForm") formData, Model model,HttpServletRequest req)throws Exception{
...
}
如何通过ajax传递params值?
答案 0 :(得分:0)
这样的事情。如果需要进一步的指导,请告诉我。
var request= new XMLHttpRequest();
request.onreadystatechange= function(){
if (request.readyState == 4 && request.status == 200) {
}
};
request.open("POST", "/home", true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send("userAction=loadHomePage");
};
设置模型对象:
var formData= new FormData();
formData.append('username' , 'payal');
formData.append('id' , 123456);
request.send(formData);