第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何將 HashSet 傳遞給服務(wù)器以測試郵遞員的 API?

如何將 HashSet 傳遞給服務(wù)器以測試郵遞員的 API?

慕容708150 2022-10-26 15:53:02
我創(chuàng)建了一個(gè)我想使用郵遞員測試的 API。我的 api 接受許多參數(shù),其中一個(gè)參數(shù)是 HashSet。我不知道如何使用郵遞員傳遞 HashSet 參數(shù)。請(qǐng)幫我。提前致謝這是我的代碼:@PutMapping    @ApiOperation(value = "collectMultiInvoices", nickname = "collectMultiInvoices")    public BaseResponse collectAmountMultipleInvoices(@RequestParam(value = "invoice_id") HashSet<Integer> invoiceIds,                                      @RequestParam("date") String _date,                                      @RequestParam(value = "cash", required = false) Float cashAmount,                                      @RequestParam(value = "chequeAmount", required = false) Float chequeAmount,                                      @RequestParam(value = "chequeNumber", required = false) String chequeNumber,                                      @RequestParam(value = "chequeDate", required = false) String _chequeDate,                                      @RequestParam(value = "chequeImage", required = false) MultipartFile chequeImage,                                      @RequestParam(value = "chequeBankName", required = false) String chequeBankName,                                      @RequestParam(value = "chequeBankBranch", required = false) String chequeBankBranch,                                      @RequestParam(value = "otherPaymentAmount", required = false) Float otherPaymentAmount,                                      @RequestParam(value = "otherPaymentType", required = false) Integer otherPaymentType,                                      @RequestParam(value = "otherPaymentTransactionId", required = false) String otherPaymentTransactionId,                                      @RequestParam(value = "discountPercentorAmount", required = false) String discountPercentorAmount,                                      @RequestParam(value = "discountId", required = false) String discountId) throws AppException.RequestFieldError, AppException.CollectionAmountMoreThanOutstanding {//method implementation}
查看完整描述

1 回答

?
蠱毒傳說

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊

SetorHashSet是一個(gè)java概念。Set從 HTTP 的角度來看,沒有 a 這樣的東西,在 Postman 中也沒有 a 這樣的東西Set。因此,從 Postman 中,您需要以invoice_idsSpring 的解析庫可以轉(zhuǎn)換為HashSet. 正如@Michael 在評(píng)論中指出的那樣,一種方法是invoice_id像這樣用逗號(hào)分隔 s: invoice_id=id1,id2,id3。當(dāng) Spring 處理此請(qǐng)求時(shí),它會(huì)看到您正在期待 a 形式的數(shù)據(jù)HashSet,因此它將嘗試轉(zhuǎn)換id1,id2,id3為 a HashSet<Integer>,它知道如何自動(dòng)執(zhí)行此操作。

旁注:除非您特別需要 a HashSet,否則使用接口而不是實(shí)現(xiàn)子類來聲明您的類型被認(rèn)為是一種好習(xí)慣。因此,在這種情況下,我建議將您的方法簽名更改為接受 aSet<Integer>而不是 aHashSet<Integer>


查看完整回答
反對(duì) 回復(fù) 2022-10-26
  • 1 回答
  • 0 關(guān)注
  • 83 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)