Struts vs Spring MVC
Struts lub moj khaum yog ib qho ntawm thawj lub vev xaib thov kev ua haujlwm rau kev tsim Java EE web applications. Caij nplooj ntoos hlav yog qhib qhov chaw thov lub moj khaum. Qee lub sij hawm tom qab kev taw qhia txog lub caij nplooj ntoos hlav, cov neeg tsim khoom tau ntxiv MVC lub hauv paus rau lub caij nplooj ntoos hlav, vam tias yuav daws qee qhov kev txwv lawv pom hauv Struts. Tab sis ob peb xyoos tom qab ntawd, Struts2 (lossis Struts version 2) tuaj txog, thiab nws tau sib txawv kiag li thiab txhim kho lub vev xaib daim ntawv thov. Tam sim no, ob qho tib si Struts thiab Spring MVC tau siv hnyav heev los tsim cov ntawv thov Java EE hauv ntiaj teb.
Struts yog dab tsi?
Struts (tseem hu ua Apache Struts) yog qhov qhib qhov qhib qhov rooj qhib lub hauv paus sau hauv Java, uas yog tsim los tsim Java EE web applications. Struts txhawb kev siv MVC (Model-View-Controller) architecture. Nws yog qhov txuas ntxiv ntawm Java Servlet API. Craig McClanahan yog tus tsim thawj ntawm Struts. Thaum xub thawj nws tau hu ua Jakaratha Struts, thiab tau khaws cia hauv Jakarta Project ntawm Apache Software Foundation. Nws qhov kev tso tawm ruaj khov tam sim no yog version 2.2.3, uas tau tso tawm thaum lub Tsib Hlis, 2011. Nws tau tso tawm raws li Apache Daim Ntawv Tso Cai 2.0. Struts lub moj khaum yog hu ua lub moj khaum raws li qhov kev thov, thiab nws yog tsim los ntawm peb lub ntsiab lus: tus neeg thov kev thov, tus neeg teb xov tooj, thiab lub tsev qiv ntawv tag. Standard URI (Uniform Resource Identifier) yog mapped rau tus neeg thov kev thov. Teb handler yog lub luag hauj lwm rau kev hloov kev tswj. Txhawm rau tsim cov ntawv thov sib tham nrog cov ntawv, cov yam ntxwv muab los ntawm lub tsev qiv ntawv lossis tuaj yeem siv. Struts txhawb cov ntawv thov REST thiab ntau yam thev naus laus zis xws li SOAP, AJAX, thiab lwm yam.
Spring MVC yog dab tsi?
Caij nplooj ntoos hlav yog qhov qhib daim ntawv thov txheej txheem. Nws yog tsim los ntawm Rod Johnson,, thiab thawj version raug tso tawm nyob rau hauv 2004. Caij nplooj ntoos hlav 3.0.5 yog tam sim no version ntawm lub caij nplooj ntoos hlav moj khaum. Nws muaj ntawv tso cai raws li Apache 2.0 daim ntawv tso cai. Txhua daim ntawv thov Java tuaj yeem siv cov yam ntxwv tseem ceeb ntawm Lub Caij Nplooj Ntoos Hlav. Muaj ob peb modules nyob rau hauv lub caij nplooj ntoos hlav moj khaum, thiab MVC yog ib tug ntawm lawv. Lub caij nplooj ntoos hlav MVC tsis yog ib feem ntawm lawv cov phiaj xwm qub. Qhov tseeb, vim li cas cov neeg tsim tawm Springs tuaj nrog lawv tus kheej MVC lub moj khaum yog los muab kev daws teeb meem rau qhov lawv tau pom tias qhov tsis zoo hauv Struts (version 1) thiab lwm cov qauv zoo sib xws. Tshwj xeeb, lawv tau hais tias lawv xav hais txog qhov tsis muaj kev sib cais ntawm cov txheej txheem nthuav qhia, thov tuav txheej, thiab cov qauv. Caij nplooj ntoos hlav MVC kuj yog qhov kev thov raws li lub vev xaib thov.
Qhov txawv ntawm Struts thiab Spring MVC yog dab tsi?
Txawm hais tias Spring MVC thiab Struts yog ob lub vev xaib nrov npe siv los tsim Java EE web applications, lawv muaj qhov sib txawv. Qhov tseeb, Caij nplooj ntoos hlav MVC tau tsim los txhawm rau daws qee qhov kev txwv hauv Struts (version 1). Tab sis Struts2 yog ib qho kev txhim kho zoo tshaj li version 1 (lawv tsis txawm qhia tib lub hauv paus), thiab yog li ntawd, Spring MVC thiab Structs2 yog qhov sib piv tau zoo heev.
Ib qhov zoo ntawm Spring MVC yog qhov ua tau kom muaj kev sib txuam nrog ntau yam kev xaiv xws li JSP / JSTL, Vuas, FreeMaker, Excel, PDF thiab JSON. Tab sis, tsis zoo li Struts, Spring MVC tsis muab kev txhawb nqa AJAX built-in (xav tau siv lub tsev qiv ntawv thib peb AJAX).
Thaum kawg, ob qho tib si suav hais tias yog lub hauv paus loj heev, thiab kev xaiv ntawm ob los ntawm tus kheej nyiam. Nws yog ib qho tseem ceeb uas yuav tsum nco ntsoov ntawm no tias yog tias muaj kev xav tsis zoo rau struts, lawv tsuas yog vim qhov tsis zoo uas tau pom hauv Struts version 1 (uas tam sim no suav tias yog siv tsis tau lawm).