Video: Vim li cas peb thiaj siv @PostMapping?
2024 Tus sau: Lynn Donovan | [email protected]. Kawg hloov kho: 2023-12-15 23:47
Los ntawm kev sau npe peb tuaj yeem pom tau tias txhua qhov kev piav qhia yog txhais tau los ua raws li cov lus thov nkag tuaj, piv txwv li @GetMapping yog siv los lis tau hom kev thov, @ PostMapping yog siv los lis POST hom kev thov txoj kev, thiab lwm yam.
Ib sab ntawm no, @PutMapping yog dab tsi?
Cov lus piav qhia rau daim phiaj HTTP PUT thov mus rau cov txheej txheem tshwj xeeb. Tshwj xeeb, @ PutMapping yog ib qho annotation uas ua raws li qhov shortcut rau @RequestMapping(txoj kev = RequestMethod.
Tsis tas li ntawd, @PatchMapping yog dab tsi? Cov lus piav qhia rau daim phiaj HTTP PATCH thov mus rau cov txheej txheem tshwj xeeb. Tshwj xeeb, @ PatchMapping yog ib qho annotation uas ua raws li qhov shortcut rau @RequestMapping(txoj kev = RequestMethod.
Kev sib raug zoo, @GetMapping yog dab tsi hauv khau raj caij nplooj ntoos hlav?
@ GetMapping annotation maps HTTP GET thov mus rau cov txheej txheem tshwj xeeb. Nws yog ib qho annotation uas ua raws li qhov shortcut rau @RequestMapping(txoj kev = RequestMethod. GET).
@RequestBody yog dab tsi?
@ Thov lub cev . Qhov no yog siv los hloov lub cev ntawm HTTP thov mus rau java class object nrog kev pab los ntawm xaiv HTTP lus converter. Cov lus piav qhia no yuav raug siv rau hauv cov txheej txheem parameter thiab lub cev ntawm http thov yuav raug mapped rau cov txheej txheem parameter.