官术网_书友最值得收藏!

How to do it...

There are a number of ways in which we can configure converters. It all depends on which one you prefer or how much control you want to achieve.

  1. Let's add ByteArrayHttpMessageConverter as @Bean to our WebConfiguration class in the following manner:
@Bean 
public  
  ByteArrayHttpMessageConverter  
    byteArrayHttpMessageConverter() { 
  return new ByteArrayHttpMessageConverter(); 
} 
  1. Another way to achieve this is to override the configureMessageConverters method in the WebConfiguration class, which extends WebMvcConfigurerAdapter, defining such a method as follows:
@Override 
public void configureMessageConverters
(List<HttpMessageConverter<?>> converters) { converters.add(new ByteArrayHttpMessageConverter()); }
  1. If you want to have a bit more control, we can override the extendMessageConverters method in the following way:
@Override 
public void extendMessageConverters
(List<HttpMessageConverter<?>> converters) { converters.clear(); converters.add(new ByteArrayHttpMessageConverter()); }
主站蜘蛛池模板: 保亭| 贵港市| 泌阳县| 桐柏县| 堆龙德庆县| 仪陇县| 容城县| 平和县| 财经| 阿拉善左旗| 仲巴县| 五大连池市| 延安市| 武安市| 安远县| 石楼县| 锦屏县| 长寿区| 新郑市| 微博| 新宾| 富阳市| 江西省| 莱阳市| 措勤县| 诏安县| 咸阳市| 新郑市| 涞源县| 浙江省| 西畴县| 个旧市| 平陆县| 汕头市| 沿河| 图们市| 开江县| 综艺| 安阳市| 延安市| 昭苏县|