属性提供了一种将信息传递到筛选器的便捷方式 链,但它们只影响当前请求。如果要传递信息 传播到嵌套的其他请求,例如 via ,或在 之后执行的请求。 例如,via ,那么您需要使用 Reactor 。flatMapconcatMapContextSpring中文文档

反应器需要填充在反应链的末端,以便 适用于所有操作。例如:ContextSpring中文文档

WebClient client = WebClient.builder()
		.filter((request, next) ->
				Mono.deferContextual(contextView -> {
					String value = contextView.get("foo");
					// ...
				}))
		.build();

client.get().uri("https://example.org/")
		.retrieve()
		.bodyToMono(String.class)
		.flatMap(body -> {
				// perform nested request (context propagates automatically)...
		})
		.contextWrite(context -> context.put("foo", ...));