码迷,mamicode.com
首页 > 编程语言 > 详细

Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public xxxxxxxx.

时间:2018-03-31 11:56:45      阅读:11619      评论:0      收藏:0      [点我收藏+]

标签:gpo   基本   except   nbsp   iss   连接   .net   基本数据   ack   

最近在使用 springBoot开发的时候, 使用PostMan访问接口,  返回一个 404 ,  后台报一个 warn :

      Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing:

          public com.syh.foundation.ResponseMessage com.xxxxx.list(xxxxx.vo.AppCostVo)

 

检查了各个类, 排查了各个可能的地方都没有发现错误, 左后在网上 查找到有人  报   : Failed to write HTTP message  错误, 其解释为:

 {      

    这个异常是我在使用Spring中,在JavaBean中使用了包装类Integer,

    private Integer  pageNum;而在方法中使用了@ResponseBody注解,

    在return  map返回给前台时Spring中的类com.fasterxml.jackson.databind.JsonMappingException

    这个类会对包装类自动拆箱成对应的基本类型,如果返回的Integer中存在null的话,那么在拆箱成int时就会报错

    如果将null赋值给包装类Integer,然后将Integer赋给各自的基本类型,编译器不会报,但是你将会在运行时期遇到空指针异常。

    这是Java中的自动拆箱导致的,任何含有null值的包装类在Java拆箱生成基本数据类型时候都会抛出一个空指针异常。

}      博客连接 :https://blog.csdn.net/wgs_93/article/details/56014607

 

write是这样的原因,  那么  read  就是 传入了空值诺  ???

我这里使用了 vo类接收参数, 并且使用 了   @requsetBody 注解,  所以与上文原因类似~~~

一检查果然是这样的。。。。。

 

Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public xxxxxxxx.

标签:gpo   基本   except   nbsp   iss   连接   .net   基本数据   ack   

原文地址:https://www.cnblogs.com/soficircle/p/8681361.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!