@PostMapping yog dab tsi?
@PostMapping yog dab tsi?

Video: @PostMapping yog dab tsi?

Video: @PostMapping yog dab tsi?
Video: Spring Boot Security Form Authentication with In-memory Users 2024, Kaum ib hlis
Anonim

Cov lus piav qhia rau daim phiaj HTTP POST thov mus rau cov txheej txheem tshwj xeeb. Tshwj xeeb, @ PostMapping yog ib qho annotation uas ua raws li qhov shortcut rau @RequestMapping(txoj kev = RequestMethod. POST).

Tsuas yog li ntawd, GetMapping thiab PostMapping yog dab tsi?

@ GetMapping yog tshwj xeeb version ntawm @RequestMapping annotation uas ua raws li ib tug shortcut rau @RequestMapping (txoj kev = RequestMethod. GET). @ GetMapping cov txheej txheem sau tseg ua haujlwm rau HTTP GET cov lus thov sib tw nrog cov lus qhia URI.

Tsis tas li ntawd, @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).

Raws li txoj cai, vim li cas peb siv @PostMapping?

@ PostMapping los lis HTTP POST Thov Daim Ntawv Ceeb Toom tias txoj kev lav phib xaub rau kev tuav HTTP POST thov yuav tsum tau sau tseg nrog @ PostMapping lus piav qhia. Daim ntawv ceeb toom yuav ua li cas @RequestBody annotation yog siv txhawm rau khij cov qauv kev sib cav uas cov ntaub ntawv JSON yuav raug hloov los ntawm Spring Framework.

MediaType Application_json_value yog dab tsi?

Txhawm rau hais qhov javadoc, MediaType . APPLICATION_JSON yog "public constant hom xov xwm rau daim ntawv thov / json ", whereas MediaType . APPLICATION_JSON_VALUE yog "Txoj hlua sib npaug ntawm MediaType . APPLICATION_JSON ". Cov cwj pwm ntawm Java annotations tsuas yog ib qho ntawm cov hom txwv xwb.