WebFlux系列(九)WebClient Uri列表、数组传参

Java#Spring#WebFlux#Reactor#WebClient#Uri#传参#数组#列表

WebClient Uri列表、数组传参

视频讲解: https://www.bilibili.com/vide...
WebFlux系列(九)WebClient Uri列表、数组传参_第1张图片

服务端:

@RestController
class EmployeeController {
    @GetMapping("employee")
    public Mono requestList(@RequestParam List names, ServerHttpRequest request){
        names.stream().forEach(System.out::println);
        return Mono.just(request.getURI().toString());
    }
}

客户端:

@RestController
class EmployeeController {
  @GetMapping("employee/{names}")
  public Mono request(@PathVariable List names) {
    return WebClient.create(baseUrl)
        .get()
        .uri(uriBuilder -> uriBuilder.path("/employee")
            .queryParam("names", names)
            .build())
        .retrieve()
        .bodyToMono(String.class);
  }
}

公众号,坚持每天3分钟视频学习
WebFlux系列(九)WebClient Uri列表、数组传参_第2张图片

你可能感兴趣的:(spring)