ModelAndView ua haujlwm li cas thaum caij nplooj ntoos hlav?
ModelAndView ua haujlwm li cas thaum caij nplooj ntoos hlav?

Video: ModelAndView ua haujlwm li cas thaum caij nplooj ntoos hlav?

Video: ModelAndView ua haujlwm li cas thaum caij nplooj ntoos hlav?
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Tej zaum
Anonim

ModelAndView yog ib yam khoom uas tuav ob lub qauv thiab saib . Tus handler rov qab ModelAndView object thiab DispatcherServlet daws qhov pom siv View Resolvers thiab View. Saib yog ib yam khoom uas muaj saib lub npe nyob rau hauv daim ntawv ntawm txoj hlua thiab qauv yog ib daim ntawv qhia ntxiv ntau yam khoom.

Tsuas yog li ntawd, vim li cas peb thiaj siv ModelAndView thaum caij nplooj ntoos hlav?

ModelAndView yog tus tuav rau ob leeg Qauv thiab Saib hauv lub vev xaib MVC. Ob chav kawm no txawv; ModelAndView tsuas yog tuav ob qho tib si los ua nws ua tau rau tus tswj kom rov qab ob leeg qauv thiab saib nyob rau hauv ib tus nqi rov qab. Kev pom yog daws los ntawm ViewResolver khoom; tus qauv yog cov ntaub ntawv khaws cia hauv Daim Ntawv Qhia.

Ib yam li ntawd, qhov txawv ntawm ModelMap thiab ModelAndView nyob rau lub caij nplooj ntoo hlav yog dab tsi? Model yog ib qho interface thaum ModelMap yog chav kawm. ModelAndView tsuas yog ib lub thawv rau ob qho tib si a ModelMap thiab View object. Nws tso cai rau tus maub los rov qab ob qho tib si raws li tus nqi.

Tsis tas li ntawd, daim ntawv thov caij nplooj ntoos hlav ua haujlwm li cas?

Nws yog lub plawv ntawm lub Caij nplooj ntoos hlav Lub moj khaum. Lub thawv IoC tau txais cov metadata los ntawm cov ntaub ntawv XML, Java annotations, lossis Java code. Lub thawv tau txais nws cov lus qhia txog cov khoom dab tsi rau instantiate, configure, thiab sib sau los ntawm yooj yim Plain Old Java Objects (POJO) los ntawm kev nyeem cov configuration metadata muab.

ModelAttribute yog dab tsi nyob rau lub caij nplooj ntoos hlav?

Ib qho tseem ceeb tshaj plaws Caij nplooj ntoos hlav -MVC annotations yog @ ModelAttribute lus piav qhia. Cov @ ModelAttribute yog ib qho annotation uas khi ib txoj kev parameter los yog txoj kev xa rov qab tus nqi rau lub npe qauv attribute thiab tom qab ntawd nthuav tawm nws mus rau lub vev xaib saib.

Pom zoo: