繁体   English   中英

如何将 api 请求的可选请求参数发送到另一个方法/函数

[英]How to send optional request parameters of an api request to another method/function

我正在尝试将我的 API 的两个或一个可选请求参数发送到另一个调用方法/function。 有人可以建议我如何,如果可能的话。

public ca.alea.cam.api.model.Response importStaticFile(@RequestBody(required = false) List<String> str, @RequestPart(required = false) MultipartFile file) throws Exception, ContentRepositoryDaoException {
...
// some code...
// I want to send str and/or file to another method
method_name(str,file);
...
}

谢谢

Just use java.util.Optional,

public ca.alea.cam.api.model.Response importStaticFile(@RequestBody(required = false) List<String> str, @RequestPart(required = false) Optional<MultipartFile> file) throws Exception, ContentRepositoryDaoException {
...
//you can check if it is present or not like below.
if(file.isPresent())
method_name(str,file);
...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM