如何使用Spring WebClient传递错误正文和StatusCode

问题描述

我有这样的请求:

    public ResponseEntity<JsonNode> test(String id) {
    return WebClient
        .create("http://localhost:8090/database/api")
        .get()
        .uri("/test/{id}",id)
        .accept(MediaType.APPLICATION_JSON)
        .exchange()
        .flatMap(resp -> resp.toEntity(JsonNode.class))
        .block();
}

请求正常时工作正常(HttpStatus代码200)

发生错误时如何返回相同的正文和HttpStatus代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)