簡體   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