Kev siv @controller thaum caij nplooj ntoos hlav yog dab tsi?
Kev siv @controller thaum caij nplooj ntoos hlav yog dab tsi?

Video: Kev siv @controller thaum caij nplooj ntoos hlav yog dab tsi?

Video: Kev siv @controller thaum caij nplooj ntoos hlav yog dab tsi?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Kaum ib hlis
Anonim

Caij nplooj ntoos hlav Controller annotation tuaj yeem siv rau ntawm cov chav kawm nkaus xwb. Nws yog siv los kos ib chav kawm raws li tus neeg thov web thov. Nws yog feem ntau siv nrog Caij nplooj ntoos hlav MVC daim ntawv thov.

Tsuas yog li ntawd, @controller ua dab tsi thaum caij nplooj ntoos hlav?

@ Tus tswj lus piav qhia yog ib annotation siv nyob rau hauv Caij nplooj ntoos hlav MVC lub moj khaum (cov ntsiab lus ntawm Caij nplooj ntoos hlav Framework siv los siv Web Application). Cov @ Tus tswj annotation qhia tias ib chav kawm tshwj xeeb ua lub luag haujlwm ntawm a tus tswj.

Kuj Paub, dab tsi yog kev siv ntawm @component hauv Caij nplooj ntoos hlav? Caij nplooj ntoos hlav Component annotation yog siv los qhia ib chav kawm li Cheebtsam . Nws txhais tau tias Caij nplooj ntoos hlav lub moj khaum yuav autodetect cov chav kawm no rau kev vam meej txhaj tshuaj thaum annotation-raws li configuration thiab classpath scanning yog siv.

Tom qab ntawd, lo lus nug yog, qhov txawv ntawm @controller thiab @RestController nyob rau lub caij nplooj ntoo hlav yog dab tsi?

Qhov txawv ntawm @ RestController thiab @ Tus tswj hauv Caij nplooj ntoos hlav . Cov @ Tus tswj yog ib qho annotation uas yog siv los kos ib chav kawm li Caij nplooj ntoos hlav MVC Tus tswj thaum @ RestController yog qhov tshwj xeeb tus tswj siv hauv RESTFul cov kev pabcuam web thiab qhov sib npaug ntawm @ Tus tswj + @ResponseBody.

Kev siv @ResponseBody yog dab tsi?

@RequestBody thiab @ Lub cev teb annotations yog siv txhawm rau khi HTTP thov / teb lub cev nrog ib tug sau khoom nyob rau hauv txoj kev parameter los yog rov qab hom. Hauv qab cov duab, cov ntsiab lus no siv HTTP Message converters los hloov lub cev ntawm HTTP thov / teb rau cov khoom sau.