webflux 相当于 WebMvcConfigurer

Seb*_*Seb 5 spring spring-mvc spring-webflux

我正在将一个应用程序表单 spring mvc 迁移到 spring webflux,但我无法弄清楚这个 webMvc conf 的等价物是什么:

@Configuration
public class PathMatchingConfigurationAdapter implements WebMvcConfigurer {

    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
        configurer.favorPathExtension(false);
    }
}
Run Code Online (Sandbox Code Playgroud)

欢迎任何想法

Bri*_*zel 5

Spring WebFlux 不支持后缀模式匹配,有关该决定背后的基本原理的更多信息,请参阅SPR-15639。

作为替代,您可以使用 aParameterContentTypeResolver做同样的事情,但带有像format=json. 您可以使用以下命令进行配置:

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {

  public void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
    builder.parameterResolver().headerResolver();
  }
}
Run Code Online (Sandbox Code Playgroud)