Required request body is missing 错误解决
今天测试接口的时候报错如下:
ERROR c.j.d.a.c.PartCleanController - Required request body content is missing: org.[email protected]8141deef
org.springframework.http.converter.HttpMessageNotReadableException: Required request body content is missing: org.[email protected]8141deef
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleEmptyBody(RequestResponseBodyMethodProcessor.java:172) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:137) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
第一反应没有反应过来是什么错误,只是感觉这个错误很熟悉,但是有很朦胧,真是该打,低级错误!!!!
Required request body content is missing 请求的主题内容不存在的错误,然后恍然大悟,这个接口请求的方式是post ,请求的body应该以json的形式写到raw里面(postMan)
如下:
controller层接收入参方式如下:
@RequestMapping(value = "v1.0/findFileDetail", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public DataResult findFileDetail(@Valid @RequestBody JdCleandataImportInVo inVo, BindingResult bindingResult) {
logger.info("request param:{}",JSONObject.toJSON(inVo));
DataResult result = new DataResult();
result.setData(jdCleandataImportService.findAllFileDetail(inVo));
logger.info("request result:{}",JSONObject.toJSON(result));
return result;
}
最后看一下浏览器中网络请求是怎样的: