前后端交互,经常出现400或者415,这里写个小笔记,已做参考,不断完善
方式一:
前台代码:
var par ={}; par.actionId =actionId; par.actionComment=actionComment; par.actionStatus=1; $.ajax({ type:'post',url:'xx/sxxx/xxxx',contentType: "application/json;charset=utf-8",data:JSON.stringify(par),dataType:'json',success:function (data) { alert(data) },error:function (){ alert('error') } });
后台代码:
@RequestMapping("/editaction") @ResponseBody public Result editaction(@RequestBody Map<String,Object> par){ return trActionManager.editactionById(par); }