从我的 JS 文件中,我发布了这个 JSON 数据。
myPayload[0].id=1&myPayload[0].name=Me&myPayload[0].pId=2&myPayload[0].pName=Dad
YUI代码:
var formElements = YAHOO.util.Connect.setForm("myFormId");
alert("New form elements:" + formElements); // Alerting POST data as shown above
YAHOO.util.Connect.resetFormState();
YAHOO.util.Connect.asyncRequest("POST", "/mycontroller/save", {
cache : false,
success : function(res) {
alert(res.responseText);
},
failure : function(res) {
alert(res.responseText);
}
}, formElements);
控制器代码:
@RequestMapping(value = "/save", method=RequestMethod.POST)
@ResponseBody
public String saveData(ModelMap mm, @ModelAttribute("myPayload") MyBean bean, BindingResult errors) {
log.info("save:Called");
List<MyDTO> lst = bean.getList();
log.info("save:Number of records:" + lst.size());
return "Successfully Updated.";
}
豆码:
public class MyBean {
private List<MyDTO> myPayload = new AutoPopulatingList<MyDTO>(MyDTO.class);
public List<MyDTO> getList() {
return myPayload;
}
public void setList(List<MyDTO> mList) {
this.myPayload = mList;
}
}
该列表仍然是空的。bean 值也是空的。我在这里做错了什么?