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

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

為其他帶有 Path 變量的 URL 選擇的默認(rèn)請(qǐng)求映射方法

為其他帶有 Path 變量的 URL 選擇的默認(rèn)請(qǐng)求映射方法

三國(guó)紛爭(zhēng) 2021-08-19 21:42:08
我有一個(gè)@RestController如下。該方法getTrain(long)應(yīng)該為 URL 獲取,http://localhost:8080/trains/1但它正在獲取getTrains(). 其他 URL 按預(yù)期工作正常。我不確定我是否遺漏或不理解某些東西。我還查看了Spring 請(qǐng)求映射到特定路徑變量值的不同方法 ,它有所幫助。要求: 1. /trains [POST] - 添加火車 2. /trains [GET] - 獲取所有火車 3. /trains/{trainId} - 通過 id 獲取火車@RestControllerpublic class TrainController {    @Autowired    private TrainService trainService;    @RequestMapping(headers = { "Accept=application/json" }, method = RequestMethod.POST)    public TrainDto addTrain(@RequestBody TrainDto trainDto) throws Exception {        return trainService.addTrain(trainDto);    }    @RequestMapping(method = RequestMethod.GET)    public List<TrainDto> getTrains() throws Exception {        return trainService.getTrains();    }    @RequestMapping(value = "{trainId:\\d+}", method = RequestMethod.GET)    public TrainDto getTrain(@PathVariable("trainId") long trainId) throws Exception {        return trainService.getTrain(trainId);    }}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 180 瀏覽

添加回答

舉報(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)