我对SpringWebFlux中的webclient有问题(webclient对象是用webclient.builder()创建的)
WebClient.RequestHeadersUriSpec uriSpec = webClient.get();
WebClient.RequestHeadersSpec<?> bodySpec = uriSpec.uri(route.getUrl());
System.out.println(route.getUrl());
return bodySpec.exchangeToMono(response -> {
System.out.println("Code : " + response.statusCode());
if (response.statusCode()
.equals(HttpStatus.OK)) {
return response.bodyToMono(classResult);
} else if (response.statusCode()
.is4xxClientError()) {
return response.bodyToMono(classResult);
} else {
return response.createException()
.flatMap(Mono::error);
}
}).doOnError(signal -> System.out.println("Erreur : " + ((WebClientRequestException)
signal).getMessage()));
我只能用doonerror方法打印错误。例如,当我有一个“webclientrequestexception:connection timed out”时,有没有方法返回一个异常或包含错误消息的特定对象?
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!