为什么webflux中的WebFilter.filter返回Mono <void>?

时间:2019-05-16 06:47:31

标签: java spring filter spring-webflux

接口public void displayMenu() { System.out.println("A. Option #A"); System.out.println("B. Option #B"); System.out.println("C. Option #C"); System.out.println("D. Option #D"); System.out.println("X. Exit!"); System.out.println(); System.out.println("Please enter your choice:"); } public void start() { displayMenu(); Scanner console = new Scanner(System.in); String input = console.nextLine().toUpperCase(); System.out.println(); switch (input) { case "A": System.out.println("Option #A was selected"); break; case "B": System.out.println("Option #B was selected"); break; case "C": System.out.println("Option #C was selected"); break; case "D": System.out.println("Option #D was selected"); break; case "X": System.out.println("You chose to Exit"); break; default: System.out.println("Invalid selection made"); break; } } public void startFor() { /*Each of these methods will modify the original start() method, each *will add a loop of the specific type so that the menu is displayed *repeatedly, until the last option is selected. When the last option *is selected, exit the method (i.e. stop the loop). */ } 强制org.springframework.web.server.WebFilter#filter返回chain.filter。因此,这只会将完整和/或错误信号转发给链。

让我们考虑2个过滤器filterA和filterB和一个请求。按照我的理解,这应该是这样工作的:

Mono<Void>

为什么不让request -> filterA(pre) -> filterB(pre) -> business code response <- filterA(post) <- filterB(post) <----' 返回chain.filter? 如何在filterA的后期修改响应?

0 个答案:

没有答案