




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
0外文原文TheDesignandRealizationofLibraryMISBasedonMVCKeywords:MVCmodel;JSP;Servlets;JavabeansAbstract.MVCisatypicalsoftwarearchitecturemodelThepaperstatesthedevelopmentprincipleandadvantagesoftheMVCpattern,discussesthesoftwaredevelopmentprocessbasedontheMVCpattern,anddesignsaWebapplicationlibrarymanagementsystem.Onthebasisofintroducingbooksmanagementsystem,thispaperdescribesthesystemdesignandimplementationmethodbasedonMVCpattern.TheuseofMVCmodelimprovesmaintainabilityandreusabilityofthesystem.INTRODUCTIONWiththerapidincreaseofthenetworkapplications,MVCparadigmisaveryadvanceddesignideaforWebapplicationdevelopment.Nomatterwhichlanguageyouchoose,nomatterhowcomplextheapplicationsare,itcanprovidethemostbasicanalysismethodfortheapplicationmodelstructural,provideacleardesigningforproducts,andprovidecanonicalreferenceforsoftwareengineering.ThisarticleraisesmanagementsystembasedonMVCparadigmonthebasisofresearchonlibrarymanagementsystem.MVCseparatestheinput,processing,andoutputofanapplicationaccordingtotheModel,ViewandController,thatis,three-tierdesignmode(namelymodellayer,viewlayerandcontrollayer).Itisnowwidelyusedinsoftwarearchitecturemodel.ThepaperusestheJSP+JavaBeans+Servlet+JDBCtechnologiestorealizetheMVCarchitecture.DisplayingWebpagesisusingJSP;realizingbusinessmodelsisusingJavaBeans,ControllingthedatatransmissionandfunctioncallbetweenforegroundandbackgroundisusingServlet;AccessingdatabaseisusingJDBC;storingdataisusingthedatabase.MVCDESIGNMODELMVCwasfirstdescribedin1979byTrygveReenskaug,thenworkingonSmalltalkatXeroxPARC.ModelViewController(MVC)isasoftwarearchitecture,currentlyconsideredanarchitecturalpatternusedinsoftwareengineering.Thepatternisolatesdomainlogic(theapplicationlogicfortheuser)fromtheuserinterface(inputandpresentation),1permittingindependentdevelopment,testingandmaintenanceofeach(separationofconcerns).A.thebasicstructureofMVCInarealapplication,thethreecomponentsofMVCareindependentandinterrelated.ThestructureandfunctionsofMVCmodelareasshowninFig.1.Themodelmanagesthebehavioranddataoftheapplicationdomain,respondstorequestsforinformationaboutitsstate(usuallyfromtheview),andrespondstoinstructionstochangestate(usuallyfromthecontroller).Inevent-drivensystems,themodelnotifiesobservers(usuallyviews)whentheinformationchangessothattheycanreact.DesignofbusinessmodelcanbesaidtobethemaincoreofMVC.Oneoftheimportantmodelsofbusinessmodelisthedatamodel.Datamodelisthedatasavingoftheentityobjects.Forexample,anorderissavedtothedatabaseorisobtainedfromthedatabase.Wecanlistthismodelseparately,alloperationsrelatedtothedatabasesarelimitedtothemodel.Theviewrepresentstheuserinterface.ItcanbedescribedasHTML,XHTML,XMLandAppletinterfacefortheWebapplication.Theviewrendersthemodelintoaformsuitableforinteraction,typicallyauserinterfaceelement.Multipleviewscanexistforasinglemodelfordifferentpurposes.Aviewporttypicallyhasaonetoonecorrespondencewithadisplaysurfaceandknowshowtorendertoit.Thecontrolleracceptstheuserrequest,matchmodelwithviewtofinishtheusersrequest.Thefunctionofdividingthecontrollayerisclear,itisadispatcherforchoosingwhatkindofmodels,choosingwhatkindofviewsandfinishingwhatkindofuserrequests.Thecontrollerreceivesinputandinitiatesaresponsebymakingcallsonmodelobjects.Acontrolleracceptsinputfromtheuserandinstructsthemodelandviewporttoperformactionsbasedonthatinput.Thecontrollercannotdoanydataprocessing.Forexample,usersclickonalink,thecontrolleracceptsrequest,anditdoesnothandlethebusinessinformation.Itpassestheusersinformationtothemodel,tellsthemodelwhattodo,choosestheviewthatmeetstherequirementstoreturntotheuser.Therefore,amodelmaycorrespondtomoreviews,andaviewmaycorrespondtomoremodels2B.thecontrolflowofMVCThoughMVCcomesindifferentflavors,controlflowisgenerallyasfollows:(1)Theuserinteractswiththeuserinterfaceinsomeway(usuallytheview,butnotnecessarily),forexample,pressesamousebutton.(2)Thecontrollerhandlestheinputeventfromtheuserinterface,oftenviaaregisteredhandlerorcallbackandconvertstheeventintoappropriateuseraction,understandableforthemodel.(3)Thecontrollernotifiesthemodeloftheuseraction,possiblyresultinginachangeinthemodelsstate.(Forexample,thecontrollerupdatestheusersshoppingcart.)(4)Aviewqueriesthemodelinordertogenerateanappropriateuserinterface(forexample,theviewliststheshoppingcartscontents).(5)Theviewgetsitsowndatafromthemodel.Insomeimplementations,thecontrollermayissueageneralinstructiontotheviewtorenderitself.Inothers,theviewisautomaticallynotifiedbythemodelofchangesinstate(Observer)whichrequireascreenupdate.Theuserinterfacewaitsforfurtheruserinteractions,whichrestartsthecycle.C.theadvantagesofMVC(1)Benefittodivisiondeployment.TodevelopapplicationusingMVCdesignpattern,personneldivisionofthedifferentfunctionsisveryclear.TousetheexampleofthedevelopmentofWebapplicationinJAVAlanguage,Javaprogrammersfocusonbusinesslogic,andinterfaceprogrammer(HTMLandJSPdevelopers)willjustconcentrateonthepageperformanceforms.(2)Increasethereuseoftheapplication.ForthesameWebapplication,theclientsmayusemultiplewaystoaccess.TheycanaccessnotonlybyHTMLbrowserofthecomputer,butalsobyWAPbrowserofthemobiletelephone.Butnomatterbywhatkindofaccessmode,thebusinesslogicandbusinessprocessoftheapplicationisthesame,youneedtochangetheconcreteimplementationwayofthepresentationlayer.MVCcansolvethisproblemeasilybecauseitrealizedtheseparationofthebusinessandview.(3)Reducecouplingandimprovethemaintainability.MVCdesignpatternseparatethe3presentationlayerandbusinesslayereffectively,itreducesthecouplingclosedegreebetweenthem.Therefore,anyalterationofthebusinesslogiccannotaffectthecodeofthepresentationlayer;thedeveloperscanmodifythecodeofthepresentationlayerfreely,andneednotrebuildthecodeofthemodelandthecontroller.D.thedisadvantagesofMVC(1)MVCisnotsuitableforthedevelopmentanddesignofsmallapplication.MVCdevelopingpersonneldividetheapplicationfullybasedonthemodel,viewandcontrol.Thiscanincreasesomeunnecessaryworkstoafewsmallapplications;thisaffectstheexploitationefficiency.(2)ProgrammingbasedonMVCdesignpatterndemandsthedevelopersmustwelldesigntheprogramstructurebeforetheprogramming;becausedividingawholeapplicationintothreecomponentsinthedesigningprocess,thisincreasesthenumberofthefileneedtomanage.SERVELETServletsaretheJavaplatformtechnologyofchoiceforextendingandenhancingWebservers.Servletsprovideacomponent-based,platform-independentmethodforbuildingWeb-basedapplications,withouttheperformancelimitationsofCGIprograms.Andunlikeproprietaryserverextensionmechanisms(suchastheNetscapeServerAPIorApachemodules),servletsareserverandplatform-independent.Thisleavesyoufreetoselectabestofbreedstrategyforyourservers,platforms,andtools.ServletshaveaccesstotheentirefamilyofJavaAPIs,includingtheJDBCAPItoaccessenterprisedatabases.ServletscanalsoaccessalibraryofHTTP-specificcallsandreceiveallthebenefitsofthematureJavalanguage,includingportability,performance,reusability,andcrashprotection.TodayservletsareapopularchoiceforbuildinginteractiveWebapplications.Third-partyservletcontainersareavailableforApacheWebServer,MicrosoftIIS,andothers.ServletcontainersareusuallyacomponentofWebandapplicationservers,suchasBEAWebLogicApplicationServer,IBMWebSphere,SunJavaSystemWebServer,SunJavaSystemApplicationServer,andothers.4TheServletisaJavaclass,anditcommunicatesandinteractswiththemodelbutdoesnotneedtogenerateHTMLorXHTMLoutput;theJSPsdonothavetocommunicatewiththemodelbecausetheServletprovidesthemwiththeinformationtheycanconcentrateoncreatingoutput.Theservletlifecycleconsistsofthefollowingsteps:(1)TheservletclassisloadedbytheWebcontainerduringstart-up.(2)Thecontainercallstheno-argumentconstructor.(3)TheWebcontainercallstheinit()method.Thismethodinitializestheservletandmustbecalledbeforetheservletcanserviceanyrequests.Intheentirelifeofaservlet,theinit()methodiscalledonlyonce.(4)Afterinitialization,theservletcanserviceclientrequests.Eachrequestisservicedinitsownseparatethread.TheWebcontainercallstheservice()methodoftheservletforeveryrequest.Theservice()methoddeterminesthekindofrequestbeingmadeanddispatchesittoanappropriatemethodtohandletherequest.Thedeveloperoftheservletmustprovideanimplementationforthesemethods.Ifarequestforamethodthatisnotimplementedbytheservletismade,themethodoftheparentclassiscalled,typicallyresultinginanerrorbeingreturnedtotherequester.(5)Finally,theWebcontainercallsthedestroy()methodthattakestheservletoutofservice.Thedestroy()method,likeinit(),iscalledonlyonceinthelifecycleofaservlet.DESIGNANDREALIZATIONOFLIBRARYMANAGEMENTSYSTEMBASEDONMVCA.OrganiccombinationofJSPServletsJavaBeansJSP+Servlets+JavaBeansisapplicationexampleofMVCpatterninJSPdevelopment,OrganicCombinationofthreecanimplementsystemfunctionwellofMVCmodel.LibrarymanagementsystemisbasedonMVCpattern;thewholemanagementsystemusesthreetierarchitectureofBrowser/Web/Database.TheclientssendrequeststoWebserverthroughbrowser,theservletrunninginserveraccepttherequests.Theservletinthesystemcanbeusedasthecontrolleroftheapplication,JSPpageisusedasviewandJavaBeanisusedasmodel.Servletreceivesallrequestssentbytheclients;itwillcallthedifferentJSPpagebasedontheacceptedrequests.Inordertofacilitatetheoperation,5sometimesServletmakesaJavaBeaninstanceusedbyJSPpagebasedonJSPpagesneeds.JSPpagecallsdirectlymethodorusestheuser-definedlabelstoobtainthedataofJavaBeaninstance.Thismethodallowstheoperationresultsreturningtotheusersintimewhenusersborrowandreturnthebooks;thismeetsthesystemreal-timerequirements.Inthisdesignmodel,datatransmissionofeverylayerisasshowninFig.2.Inthissystem,themodelisacollectionofJavaclassesthatformasoftwareapplicationintendedtostore,andoptionallyseparate,data.Asinglefront-endclassthatcancommunicatewithanyuserinterface(forexample:aconsole,agraphicaluserinterface,orawebapplication).TheviewisrepresentedbyaJavaServerPage,withdatabeingtransportedtothepageintheHttpServletRequestorHttpSession.TheControllerservletcommunicateswiththefrontendofthemodelandloadstheHttpServletRequestorHttpSessionwithappropriatedata,beforeforwardingtheHttpServletRequestandResponsetotheJSPusingaRequestDispatcher.B.designandrealizationoflibrarymanagementsystemThefunctionalrequirementsblockdiagramofthelibrarymanagementsystemisasshowninFig.3;theinformationquerymoduleisasshowninFig4.Theusecaseistheinteractionbetweenthesystemandtheusers;itpaysattentiontotheexternalusers.Theuserscanunderstandthesystemfunctionsbyusecase.Inthissystem,theusecaseisasshowninFig.5.Thecodesofthedatabaseconnectionisasfollows:/creatingthedatabaseconnectionpublicConnectiongetConnection()throwsExceptionClass.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);con=DriverManager.getConnection(jdbc:microsoft:sqlserver:/localhost:1433;DatabaseName=MyLibrary,sa,123);returncon;6Figure1.ThestructureandfunctionsofMVCmodelFigure2.DatatransmissioninMVC7Figure3.TheblockdiagramofthelibrarymanagementsystemFigure4.TheinformationquerymoduleCONCLUSIONSMVCdesignpatternmeetstheinterfacedemand;separatethecalculatingmodelofthe8softwarefromtheinterfaceconstitute.Itcanbuildandusemulti-viewswhenthemodelisrunning.Themodelhasportability,andisapotentialframestructure.Thelibrarymanagementsystemrealizedthemodulesofuserlogin,basicbusiness,DBmanagementandinformationquery,implementedpaperlessfiling,savedthecost.TheuseofMVCpatternreducesthecomplexityinarchitecturaldesignandincreasesflexibilityandmaintainabilityofcode,enhancedthedevelopmentefficiencyofthesystem.Figure5.Theusecaseoflibrarymanagementsystem9中文翻译基于MVC模式的图书馆信息管理系统的设计与实现关键词:MVC模式;JSP;Servlet;JavaBean摘要:MVC是一个典型的软件体系结构模型,阐述了MVC模式开发的原理和优势,论述了基于MVC模式的软件开发过程,并设计了一个Web应用的图书馆管理系统。在介绍了图书管理系统的基础上,本文介绍了基于MVC模式的方法的系统的设计与实现。MVC模式的使用提高了系统的可维护性和可重用性。引言随着网络应用的快速增加,MVC模式是Web应用开发的一个非常先进的设计理念。无论你选择哪种语言,无论多么复杂的应用程序,它可以为应用程序提供的模型结构最基本的分析方法,为产品提供一个明确的设计,并提供软件工程规范的参考。本文提出了基于MVC模式对图书馆管理系统研究的基础上管理系统。MVC设计模式分离的输入,处理,输出一个应用程序根据模型,视图和控制器,即,三层设计模式(即模型层,视图层和控制层)。它是目前广泛使用的软件体系结构模型。本文采用JSP+JavaBeans+SERVLET+JDBC技术来实现MVC架构。显示Web页面使用JSP实现业务模型;利用JavaBeans,控制和数据传输功能的前景和背景之间的呼叫使用Servlet;数据库的访问使用JDBC;存储数据用的是数据库。MVC设计模式MVC最初是在1979由TrygveReenskaug,然后在Smalltalk在施乐帕洛阿尔托研究中心。模型视图控制器(MVC)是软件体系结构,目前被认为是软件工程中使用的建筑模式。模式分离”域逻辑”(为用户应用程序逻辑)从用户接口(输入和演示),允许独立发展,每个测试和维护(关注点分离)。A.MVC的基本结构在实际的应用中,MVC的三个组成部分是独立的和相互关联的。MVC模型的结构和功能,如图1所示。模型管理的应用程序域的行为和数据,根据其状态信息请求(通常是从视图),和响应指令来改变状态(通常由控制器)。在事件驱动的系统模型,观察者(通常是通知视图)时,信息的变化,使他们能够作出反应。业务模型的设计可以说是MVC核心。一个商业模式的重要模型是数据模型。数据模型是数据存储的实体对象。例如,为了保存到数据库或从数据库中获得的。我们可以列出这个模型,所有的数据库操作仅限于模型。视图表示用户界面。它可以被描述为HTML,XHTML,XML为Web应用程序接口。视图渲染模型成适合于互动的形式,通常是一个用户界面元素。多个视图可以用10于不同目的的单一模式的存在。一个视口,通常有一一对应一个显示面和知道如何使它。控制器接受用户的请求,以完成用户的请求匹配模型。划分控制层的作用是明确的,它是一个选择什么样的模型调度,选择什么样的观点和完成什么样的用户请求。控制器接收输入的模型对象进行调用,发起一个响应。控制器接收来自用户输入和指导模型和视图的基础上执行输入操作。控制器不能做任何的数据处理。例如,用户点击一个链接,控制器接受请求,它不处理商业信息。它通过用户的信息模型,对模型做什么,选择符合要求返回到用户视图。因此,一个模型可能对应多个视图,以及视图可以对应于多个模型B.MVC的控制流虽然MVC有不同的口味,控制流程一般如下:(1)用户以某种方式与用户交互界面(通常的观点,但不一定),例如,按下鼠标按钮。(2)控制器处理输入事件从用户界面,往往通过注册处理程序或回调将事件到适当的用户行为,可以理解为模型。(3)控制器通知用户行为模型,可能会导致在模型中的状态的变化。(例如,控制器更新用户的购物车。)(4)一个视图的查询模型,以产生适当的用户界面(例如,视图列出购物车的内容)。(5)从模型中获取自己的数据。在一些实施例中,控制器可以发出指令给视图渲染自己。在其他情况下,视图自动通知状态变化的模型(观察者)需要一个屏幕更新。用户界面有待进一步的用户交互,并重新启动循环。C.MVC的优势(1)有利于分工部署。开发使用MVC设计模式的应用,不同功能的人员分工非常明确。利用Java语言的Web应用程序开发的实例,Java程序员专注于业务逻辑和界面,程序员(HTML和JSP开发人员)将专注于页面表现形式。(2)提高了应用程序的复用。对同一个Web应用程序,客户可以使用多种方式来访问。他们可以访问不仅通过HTML浏览器的计算机,而且通过WAP浏览器的移动电话。但没有哪种接入方式问题,应用程序的业务逻辑和业务过程是相同的,你需要改变表示层的具体实现方式。MVC可以解决这个问题很容易因为它实现了业务的分离和视图。(3)降低耦合度,提高系统的可维护性。MVC设计模式分离了表示层和业务层有效,它降低了它们之间的耦合度。因此,任何改变的业务逻辑不能影响表示层代码;开发商可以自由修改表现层的代码,而不需要重建代码的模型和控制器。11D.MVC的缺点(1)MVC是不适合与小应用程序的设计开发。MVC开发人员将完全基于模型的应用,查看和控制。这可以增加一些不必要的工作,一些小的应用程序的开发效率;影响。(2)基于MVC设计模式的编程要求开发商必须在规划设计的程序结构;由于将整个应用程序分为三个部分,在设计的过程中,这增加了文件的数量需要管理。ServletServlets是扩大和加强Web服务器选择Java平台技术。Servlet提供组件,构建基于Web的应用程序独立于平台的方法,没有CGI程序的性能限制。不像专有服务器扩展机制(如Netscape服务器API或Apache模块),Servlets服务器平台无关。这给你自由去选择一个“最佳”的策略,你的服务器,平台,和工具。Servlet访问JavaAPI的整个家庭,包括JDBCAPI访问企业数据库。servlet也可以访问特定的HTTP调用库和收到的所有好处的成熟的Java语言,包括便携性,性能,可重用性,和碰撞保护。今天的servlet是构建交互式Web应用程序的一个受欢迎的选择。第三方的servlet容器提供微软IIS,ApacheWeb服务器,和其他人。servlet容器通常是Web服务器和应用服务器组件,如BEAWebLogic应用服务器,IBMWebSphere,SunJava系统的Web服务器,SunJava应用服务器,和其他人。Servlet是一个Java类,它沟通和交互模型而不需要生成
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文化创意产业园区文化创意产业园区文化创意产业园区文创产品市场分析与消费者偏好研究报告
- 2025年教育精准扶贫对农村学校教学资源的影响分析
- 中医有关肛痈试题及答案
- 2025年中医药现代化国际市场拓展:尼泊尔市场深度研究报告
- 模具制造数字化设计2025年在轨道交通装备中的应用与优化报告
- 人力资源管理师一级《理论知识》考试试题及答案
- 德州市陵城区人民医院招聘笔试真题2024
- 企业测评题库及答案
- 培训考试题及答案
- pb编程题目及答案
- 中国成人患者肠外肠内营养临床应用指南(2023版)解读课件
- (完整版)四年级乘除法竖式练习题(每日20题)
- 建筑垃圾清运服务投标方案技术标
- 勾股定理知识点和习题(附答案)
- 充电桩或充电站日常检查表、月度检查表(BG-AQ-044~045)
- 2023-2024年七年级期末语文考试试卷
- 胃息肉中医治疗方法
- 执业医师法培训课件
- 2024年湖南常德芙蓉大亚化纤有限公司招聘笔试参考题库含答案解析
- 20222023学年辽宁省抚顺市沈抚育才实验学校八年级(上)期末语文试卷(解析)
- 神经科护士的疼痛管理和舒适护理
评论
0/150
提交评论