jsp:
var postData = {
id: $("#id").val(),
name: name,
list: list
};
$.ajax({
type: "POST",
url: '<%=basePath%>data/save.do',
//data: postData,
data: JSON.stringify(postData),
dataType:'json',
contentType : 'application/json;',
cache: false,
success: function(data){
if("ok" == data.msg){
}else{
}
}
});
Controller:
@RequestMapping(value="/save")
@ResponseBody
public Object save(@RequestBody Survey survey) throws Exception{
Map<String, String> map = new HashMap<String, String>();
try {
} catch (Exception e) {
logger.error(e.toString(), e);
map.put("msg", "error");
}
return map;
}
public class Survey {
private String id;
private String name;
private List list = new ArrayList();
// set 和get方法 省略
...
...
}
Form 提交
$("#Form").ajaxSubmit(function(data){
});