使用Netty服务器在Spring WebFlux中控制器之后是否有WebFilter火灾?
我正在寻找Spring Webflux中的Servlet 过滤器
等效。 WebFilter
似乎仅在控制器之前触发,但不在后面发射。例如,我可以在请求进来时添加WebFilter
做某事,但是当响应退回时,我找不到等效的“过滤器”来执行某件事。
您能以两种方式发射一个“过滤器”吗?
I am looking for servlet Filter
equivalent in Spring WebFlux. The WebFilter
seems to only fires before the controller but not after. e.g I can add a WebFilter
to do something when a request comes in, but I couldn't find an equivalent "filter" to do something when a response is sending back.
Can you have a "filter" that fires in both ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需在
webfilterchain.filter
调用之后添加代码。Just add code after the
webFilterChain.filter
call.您仍然可以使用
WebFilter
也可以修改服务器的出站响应。这是在响应中添加标头的示例:参考: https://www.baeldung.com /spring-webflux-filters
You can still use
WebFilter
to modify your server's outbound responses as well. Here's an example of adding a header to the response:Reference: https://www.baeldung.com/spring-webflux-filters
我认为您要寻找的技巧是当您在过滤器方法中调用过滤器链时,您想要以下
I think the trick you are looking for is when you call the filter chain in the filter method you want the following