js:表单->json对象
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [ o[this.name] ];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$("#btn_save").click(function(){
var formData = $("#archivecase").serializeObject();
if (validform().form()) {
$.ajax({
url:"",
type:"post",
data:JSON.stringify(formData),
contentType: "application/json",
success:function(data){
},
})
}
})
controller:
@RequestMapping(value=" ",method=RequestMethod.POST)
@ResponseBody
public String addArchiveCase(@RequestBody Archive archive){