@InitBinder public void initBinder(WebDataBinder binder) { this.binder = binder; }
when processing a regular request, the function can be called, but if the first request is an ajax request
@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(); }
the initBinder function is not called, the binder is null. that really confuse me
source share