我是
Spring MVC的新手.
我有这样的形式,
< form:form acion =“/ myaction.htm”method =“post”modelAttribute =“myForm”id =“formid”>和返回json的控制器
public @ResponseBody ResultObject doPost(@ModelAttribute(“myForm”)MyForm myForm){
系统输出( “myform.input”);
}
我可以使用$(“#formid”)提交它.submit();我的modelAttribute正常工作,从UI获取值.
我的问题是,如何以jquery ajax的方式提交此表单?
我试过这个,
$.ajax({
type:"post",
url:"/myaction.htm",
async: false,
dataType: "json",
success: function(){
alert("success");
}
});
该表单被提交,但是modelAttribute值是null,在提交时如何包括modelAttribute对象(表单正在使用的对象)?