> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/27.-developing-web-applications/27.2-the-spring-webflux-framework/27.2.2-http-codecs-with-httpmessagereaders-and-httpmessagewriters.md).

# 27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters

Spring WebFlux使用`HttpMessageReader`和`HttpMessageWriter`接口转换HTTP请求与回应。它们由`CodecConfigurer`配置——通过查看类路径里可用的库配置默认值。

Spring Boot通过使用`CodecCustomizer`实例，更进一步地实现自定义。比如，`spring.jackson.*`配置键被应用于Jackson编解码器。

如果你需要添加或自定义编解码器，你可以创建一个自定义的`CodecCustomizer`组件，如下所示：

```java
import org.springframework.boot.web.codec.CodecCustomizer;

@Configuration
public class MyConfiguration {

    @Bean
    public CodecCustomizer myCodecCustomizer() {
        return codecConfigurer -> {
            // ...
        }
    }

}
```

你也可以利用[Spring Boot的自定义JSON序列化器和反序列化器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components)。
