java - 如何使用 Spring Boot WebClient 通过发布请求发送多个值?
问题描述
如您所见,在我的服务层中,此方法使用 Spring Boot WebClient 框架向服务器发送类似客户端的 post 请求,但我遇到了一个问题,正如您所看到的,我的方法接受 4 个参数,您看到了并且我想要仅将这 3 个参数发送到服务器。我想知道如何设置多个参数以使用 WebClient 发送?什么方法支持这个?
@Override
public Mono<ResponseEntity<? extends ResponseResource>> sendSms(String message, List<BulkSmsRequestResource> request, String originatorName, String sendSmsApi) {
if (request == null) {
return Mono.just(new ResponseEntity<>(
new ErrorResponseResource(
"Transaction failed successfully!",
400),
HttpStatus.BAD_REQUEST));
}
Mono<BulkSmsRequestResource> bulkSmsRequestResourceMono = webClientBuilder.build()
.post()
.uri(sendSmsApi)
.body(Mono.just(request), BulkSmsRequestResource.class)
.retrieve()
.bodyToMono(BulkSmsRequestResource.class);
bulkSmsRequestResourceMono.subscribe();
return Mono.just((new ResponseEntity<>(new SuccessResponseResource("Transaction done successfully", 200), HttpStatus.OK)));
}
解决方案
推荐阅读
- directx - DirectX 和 DirectXTK 翻译限制
- flutter - Flutter 获取键盘按键虚拟代码 [Windows]
- python - Alembic 使用环境变量切换多个数据库
- reactjs - 使用 ant 设计框架如何从 dorpdown/comboboxs 更新 initialValue
- sql - 当参数是记录的一部分时如何运行NTILE sql函数
- vue.js - v-select / v-combobox中的Vuetify更改复选框图标
- selenium - 使用webdriver IO(wdio V7)时如何在“onPrepare”挂钩上停止硒安装
- javascript - Vue - 我如何在窗口中加载组件?
- java - 在 Eclipse 中获取 SSL 异常
- perforce - 需要从文件中删除多个用户的权限