springboot|springboot 之 springmvc HttpMessageConverters

首先请先理解下面这一段话:
Spring MVC uses the HttpMessageConverter interface to convert HTTP requests and responses. Sensible defaults are included out of the box. For example, objects can be automatically converted to JSON (by using the Jackson library) or XML (by using the Jackson XML extension, if available, or by using JAXB if the Jackson XML extension is not available). By default, strings are encoded in UTF-8
上面是说 springmvc提供了HttpMessageConverter 接口,用户可以实现接口来转换http请求和响应,比如我们实现请求的序列化和响应的反序列化,
如果想要自己实现接口,还必须将实现类加入converts中


springboot|springboot 之 springmvc HttpMessageConverters
文章图片


下面是实现json序列化和反序列化例子
【springboot|springboot 之 springmvc HttpMessageConverters】

springboot|springboot 之 springmvc HttpMessageConverters
文章图片

    推荐阅读