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

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

Spring Boot @RequestMapping 是否完全匹配請求?

Spring Boot @RequestMapping 是否完全匹配請求?

胡子哥哥 2021-06-28 09:59:35
我有一個(gè) Spring Boot API,它有提供分頁的端點(diǎn)。@RequestMapping(path = "/most-popular", method = GET)@Overridepublic List<RefinedAlbum> getMostPopularDefault() {    return albumService.getMostPopular(0, 25);}@RequestMapping(path = "/most-popular?offset={offset}&limit={limit}", method = GET)@Overridepublic List<RefinedAlbum> getMostPopular(@PathVariable("limit") int limit, @PathVariable("offset") int offset) {    inputValidation(limit, offset);    return albumService.getMostPopular(limit, offset);}但是當(dāng)我向服務(wù)提出請求時(shí):http://localhost:5250/api/v1/albums/most-popular?offset=100&limit=125第一個(gè)函數(shù)被調(diào)用。我的理解是應(yīng)該先進(jìn)行精確匹配。那不正確嗎?
查看完整描述

1 回答

?
慕無忌1623718

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

?以下 URL 中的之后的內(nèi)容不能使用@PathVariable注釋綁定:


http://localhost:5250/api/v1/albums/most-popular?offset=100&limit=125

您的路徑只是http://localhost:5250/api/v1/albums/most-popular,之后的內(nèi)容由兩個(gè)請求參數(shù)組成,即。offset和limit。您可以使用@RequestParam注解將請求參數(shù)綁定到控制器中的方法參數(shù):


@RequestMapping(path = "/most-popular", method = GET)

@Override

public List<RefinedAlbum> getMostPopular (@RequestParam("limit") int limit, 

   @RequestParam("offset") int offset) {

   inputValidation(limit, offset);

   return albumService.getMostPopular(limit, offset);

}


查看完整回答
反對 回復(fù) 2021-07-14
  • 1 回答
  • 0 關(guān)注
  • 239 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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