and 方法(在 Kotlin 中为 and)
对于需要更多控制的更高级的情况非常有用,例如以不同的方式解码响应
取决于响应状态:exchangeToMono()exchangeToFlux()awaitExchange { }exchangeToFlow { }
- 
Java
 - 
Kotlin
 
Mono<Person> entityMono = client.get()
		.uri("/persons/1")
		.accept(MediaType.APPLICATION_JSON)
		.exchangeToMono(response -> {
			if (response.statusCode().equals(HttpStatus.OK)) {
				return response.bodyToMono(Person.class);
			}
			else {
				// Turn to error
				return response.createError();
			}
		});
val entity = client.get()
  .uri("/persons/1")
  .accept(MediaType.APPLICATION_JSON)
  .awaitExchange {
		if (response.statusCode() == HttpStatus.OK) {
			 return response.awaitBody<Person>()
		}
		else {
			 throw response.createExceptionAndAwait()
		}
  }
使用上述内容时,在 returned 或 complete 之后,响应正文
被选中,如果未使用,则释放它以防止内存和连接泄漏。
因此,响应不能进一步在下游解码。这取决于提供的
函数来声明如何在需要时解码响应。MonoFlux