今天遇到一个诡异的Bug,使用Postman发post请求,访问本地的Controller,Debug模式下,看到Controller解析出的入参一直是null,代码如下:
@RequestMapping(value = "/notifyLDX", method = {RequestMethod.POST})
@FSPServiceInfo(name = "FBS.SPA.ShareRegApi.notifyLDX", description = "notify LDX")
public void notifyLDX(@Json ActiveTaskInputDto param, HttpServletResponse response) {
log.info("ShareRegApi.notifyLDX param : " + JsonUtil.toString(param));
RestUtil.write(response, JsonUtil.toString(activeMemberInfoService.notifyLDX(param)));
}
凭直觉,应该是JSON参数格式不对,导致解析出错,果然,仔细看了下请求参数,发现日期格式错误,例如你的日期是Date,但实际你传的是String,这时就要调整日期格式,改好日期格式后,再次发送post,调用成功。