MVC外文翻译.docx
- 文档编号:2808732
- 上传时间:2022-11-15
- 格式:DOCX
- 页数:15
- 大小:77.83KB
MVC外文翻译.docx
《MVC外文翻译.docx》由会员分享,可在线阅读,更多相关《MVC外文翻译.docx(15页珍藏版)》请在冰豆网上搜索。
MVC外文翻译
外文翻译
学院:
信息科学与工程学院
专业:
计算机科学与技术
*******
学生班级:
计算机0801班
学生学号:
*********
*******
指导教师评语
指导教师签名:
年月日
Struts——anopen-sourceMVCimplementation
ThisarticleintroducesStruts,aModel-View-ControllerimplementationthatusesservletsandJavaServerPages(JSP)technology.StrutscanhelpyoucontrolchangeinyourWebprojectandpromotespecialization.EvenifyouneverimplementasystemwithStruts,youmaygetsomeideasforyourfutureservletsandJSPpageimplementation.
Introduction
KidsingradeschoolputHTMLpagesontheInternet.However,thereisamonumentaldifferencebetweenagradeschoolpageandaprofessionallydevelopedWebsite.Thepagedesigner(orHTMLdeveloper)mustunderstandcolors,thecustomer,productflow,pagelayout,browsercompatibility,imagecreation,JavaScript,andmore.Puttingagreatlookingsitetogethertakesalotofwork,andmostJavadevelopersaremoreinterestedincreatingagreatlookingobjectinterfacethanauserinterface.JavaServerPages(JSP)technologyprovidesthegluebetweenthepagedesignerandtheJavadeveloper.
Ifyouhaveworkedonalarge-scaleWebapplication,youunderstandthetermchange.Model-View-Controller(MVC)isadesignpatternputtogethertohelpcontrolchange.MVCdecouplesinterfacefrombusinesslogicanddata.StrutsisanMVCimplementationthatusesServlets2.2andJSP1.1tags,fromtheJ2EEspecifications,aspartoftheimplementation.YoumayneverimplementasystemwithStruts,butlookingatStrutsmaygiveyousomeideasonyourfutureServletsandJSPimplementations.
Model-View-Controller(MVC)
JSPtagssolvedonlypartofourproblem.Westillhaveissueswithvalidation,flowcontrol,andupdatingthestateoftheapplication.ThisiswhereMVCcomestotherescue.MVChelpsresolvesomeoftheissueswiththesinglemoduleapproachbydividingtheproblemintothreecategories:
∙Model
Themodelcontainsthecoreoftheapplication'sfunctionality.Themodelencapsulatesthestateoftheapplication.Sometimestheonlyfunctionalityitcontainsisstate.Itknowsnothingaboutthevieworcontroller.
∙View
Theviewprovidesthepresentationofthemodel.Itisthelookoftheapplication.Theviewcanaccessthemodelgetters,butithasnoknowledgeofthesetters.Inaddition,itknowsnothingaboutthecontroller.Theviewshouldbenotifiedwhenchangestothemodeloccur.
∙Controller
Thecontrollerreactstotheuserinput.Itcreatesandsetsthemodel.
MVCModel2
TheWebbroughtsomeuniquechallengestosoftwaredevelopers,mostnotablythestatelessconnectionbetweentheclientandtheserver.Thisstatelessbehaviormadeitdifficultforthemodeltonotifytheviewofchanges.OntheWeb,thebrowserhastore-querytheservertodiscovermodificationtothestateoftheapplication.
Anothernoticeablechangeisthattheviewusesdifferenttechnologyforimplementationthanthemodelorcontroller.Ofcourse,wecoulduseJava(orPERL,C/C++orwhatever)codetogenerateHTML.Thereareseveraldisadvantagestothatapproach:
∙Javaprogrammersshoulddevelopservices,notHTML.
∙Changestolayoutwouldrequirechangestocode.
∙Customersoftheserviceshouldbeabletocreatepagestomeettheirspecificneeds.
∙Thepagedesignerisn'tabletohavedirectinvolvementinpagedevelopment.
∙HTMLembeddedintocodeisugly.
FortheWeb,theclassicalformofMVCneededtochange.Figure1displaystheWebadaptationofMVC,alsocommonlyknownasMVCModel2orMVC2.
Figure1.MVCModel2
Struts,anMVC2implementation
Strutsisasetofcooperatingclasses,servlets,andJSPtagsthatmakeupareusableMVC2design.ThisdefinitionimpliesthatStrutsisaframework,ratherthanalibrary,butStrutsalsocontainsanextensivetaglibraryandutilityclassesthatworkindependentlyoftheframework.Figure2displaysanoverviewofStruts.
Figure2.Strutsview
Strutsoverview
●Clientbrowser
AnHTTPrequestfromtheclientbrowsercreatesanevent.TheWebcontainerwillrespondwithanHTTPresponse.
●Controller
TheControllerreceivestherequestfromthebrowser,andmakesthedecisionwheretosendtherequest.WithStruts,theControllerisacommanddesignpatternimplementedasaservlet.Thestruts-config.xmlfileconfigurestheController.
●Businesslogic
Thebusinesslogicupdatesthestateofthemodelandhelpscontroltheflowoftheapplication.WithStrutsthisisdonewithanActionclassasathinwrappertotheactualbusinesslogic.
●Modelstate
Themodelrepresentsthestateoftheapplication.Thebusinessobjectsupdatetheapplicationstate.ActionFormbeanrepresentstheModelstateatasessionorrequestlevel,andnotatapersistentlevel.TheJSPfilereadsinformationfromtheActionFormbeanusingJSPtags.
●View
TheviewissimplyaJSPfile
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MVC 外文 翻译