有时候当上传的数据参数很多的时候,会用model打包上传,但是如果服务端的解析方式不当,无论你怎么上传,服务端解析到的数据包里面数据都是null
服务端请用ResponseBody
客户端:
@POST("FenceSetting/add") Observable<MyHttpResponse<FenceBean>> addFence(@Body RequestBody fenceSetting);
服务端:
@InitBinder("fenceSetting") public void initBinderUser(WebDataBinder binder) { binder.setFieldDefaultPrefix("fenceSetting."); } @RequestMapping(value="/add", method = RequestMethod.POST) public @ResponseBody JSONResponse<FenceSetting> add(@RequestBody FenceSetting fenceSetting) throws Exception{ mapper.insert(fenceSetting); return new JSONResponse<FenceSetting>(fenceSetting, MsgConstant.success_cd,MsgConstant.success, true); }