转:http://blog.sina.com.cn/s/blog_7611e3d70100q4et.html
1、如果是通过表单BASEFORM的SUBMIT,或是Ext.Ajax.request发送:
Ext.Ajax.request({
url: this.removeUrl,
method:'POST',
success: function(res, opts){
Ext.Msg.alert('揭示','删除成功!');
},
failure: function(res, opts){
Ext.Msg.alert('揭示','删除失败。'+res.responseText);
},
params:{id:n.id,parentId:n.parentId,name:n.name},
scope:this
});
则在后台可以用COMMAND的模式来接收:
@RequestMapping(value = "/merge")
@ResponseBody
public String merge(SysModule module) {
String result = null;
log.debug(module.getId());
module = moduleManager.save(module);
return result;
}
如果是通过url?param=xxx这样的方式发送,后台则可用@RequestParam的参数来接收。
2、还有一种方式是用@RequestBody的方式来接收发送到后台的JSON数据,记住要把CONTENT-TYPE设为:application/json; charset=utf-8,然后request的参数是用jsonData来传递:
Ext.Ajax.request({ url: this.removeUrl, method:'POST', headers:{ 'Content-Type': 'application/json; charset=utf-8' }, success: function(res, opts){ ... }, failure: function(res, opts){ ... }, jsonData:{id:n.id,parentId:n.parentId,action:n.action}, scope:this });