Video: @ResponseBody annotation nyob rau lub caij nplooj ntoos hlav yog dab tsi?
2024 Tus sau: Lynn Donovan | [email protected]. Kawg hloov kho: 2023-12-15 23:47
Cov lus siv: Java, JSON
Ntxiv mus, @RequestBody thiab @ResponseBody annotations nyob rau lub caij nplooj ntoos hlav yog dab tsi?
@RestController yog tus tsim lus piav qhia uas yog nws tus kheej meta- sau tseg nrog @Controller [email tiv thaiv] Lub cev teb los qhia txog tus maub los uas nws txhua txoj kev tau txais cov hom-theem @ ResponseBody annotation thiab, yog li ntawd, sau ncaj qha mus rau lub teb lub cev tiv thaiv kev daws teeb meem thiab ua tiav nrog HTML qauv.
Kuj Paub, @RestController annotation yog dab tsi nyob rau lub caij nplooj ntoo hlav? Spring RestController annotation yog ib qho yooj yim lus piav qhia uas yog nws tus kheej sau tseg nrog @Controllerand @ResponseBody. Qhov no lus piav qhia yog siv rau ib chav kawm tomark nws raws li ib tug thov handler. Spring RestControllerannotation yog siv los tsim RESTful web kev pabcuam siv Caij nplooj ntoos hlav MVC.
Yog li ntawd, @RequestBody annotation nyob rau lub caij nplooj ntoos hlav yog dab tsi?
@ Thov lub cev thiab @ ResponseBody annotations yog siv los khi HTTP thov / teb lub cev nrog domainobject hauv cov txheej txheem parameter lossis hom rov qab. Hauv qab scenes, cov no lus piav qhia siv HTTP Message converters los hloov lub cev ntawm HTTP thov / teb rau cov khoom sau.
Kev siv @RestController annotation yog dab tsi?
Tus @Controller yog ib yam lus piav qhia uas yog siv kos ib chav kawm li Spring MVC Controller [email tiv thaiv] RestController yog tus tswj tshwj xeeb siv inRESTFul cov kev pabcuam web thiab qhov sib npaug ntawm @Controller [email tiv thaiv]