@InitBinder
public void initBinder(WebDataBinder binder) {
this.binder = binder;
}
处理正常请求时,可以调用该函数,但如果第一个请求是ajax请求
@RequestMapping("create")
@ResponseBody
public String create(@RequestBody String body) {
JSONObject result = new JSONObject();
try{
JSONObject params = new JSONObject(body);
T t = buildEntity(params);
service().save(t);
result.put(ExtConstant.DATA, t.detailJson());
result.put(ExtConstant.SUCCESS, true);
}catch(Exception e){
result.put(ExtConstant.SUCCESS, false);
result.put(ExtConstant.ERROR_MSG, e.getMessage());
e.printStackTrace();
}
return result.toString();
}
未调用函数initBinder,binder为null。那让我很困惑