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

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()); }
主站蜘蛛池模板: 定兴县| 铁岭市| 常山县| 盖州市| 文成县| 萨迦县| 山东省| 罗山县| 蒙阴县| 汝城县| 和硕县| 阜平县| 阿鲁科尔沁旗| 甘南县| 通许县| 集安市| 石景山区| 阳高县| 吉木乃县| 焉耆| 平和县| 丹寨县| 东安县| 台中县| 田林县| 霍山县| 浮梁县| 临汾市| 山阳县| 安义县| 灵武市| 莱阳市| 定西市| 彭泽县| 丁青县| 吴江市| 贡嘎县| 土默特左旗| 平塘县| 根河市| 常德市|