Spring boot Spring Flux:如何配置多个WebFilter

Spring boot Spring Flux:如何配置多个WebFilter,spring-boot,spring-webflux,Spring Boot,Spring Webflux,我正在编写一个SpringWebFlux应用程序。我创建了两个WebFilter组件: 字母过滤器 身份验证过滤器 我想确保AuthenticationFilter在AlphaFilter之前运行。如何配置过滤器,使AuthenticationFilter在AlphaFilter之前运行?Sagar 回答你的问题了吗 在WebHandler API中,可以使用WebFilter应用 其余处理前后的拦截样式逻辑 过滤器链和目标WebHandler。使用WebFlux时 在配置中,注册WebFilt

我正在编写一个SpringWebFlux应用程序。我创建了两个WebFilter组件:

字母过滤器

身份验证过滤器

我想确保AuthenticationFilter在AlphaFilter之前运行。如何配置过滤器,使AuthenticationFilter在AlphaFilter之前运行?

Sagar

回答你的问题了吗

在WebHandler API中,可以使用WebFilter应用 其余处理前后的拦截样式逻辑 过滤器链和目标WebHandler。使用WebFlux时 在配置中,注册WebFilter就像将其声明为 Springbean和可选的通过在上使用@Order来表示优先级 bean声明或通过实现Ordered


谢谢@Stepan。添加了AuthenticationFilter的@Order1注释和AlphaFilter上的@Order2注释。这很有帮助。
class AlphaFilter implement WebFilter {
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        // ....
        // Alpha Filter Configurations
        return chain.filter(exchange);
    }
}
class AuthenticationFilter implement WebFilter {
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        // ....
        // Alpha Filter Configurations
        return chain.filter(exchange);
    }
}