本科生毕业设计 (论文)外文翻译原文标题MVC Design Pattern for the multi frameworkdistributed applications using XML, spring and strutsframework译文标题使用XML,Spring和struts以MVC为设计模式的多分布式应用程序框架作者所在系别计算机与遥感信息技术学院作者所在班级B12511作者姓名王硕作者学号20124051117指导教师姓名耿炎指导教师职称院长完成时间2015 年1 月北华航天工业学院教务处制译文标题使用XML,Spring和struts以MVC为设计模式的多分布式应用程序框架原文标题MVC Design Pattern for the multi frameworkdistributed applications using XML, spring and struts framework作者Praveen Gupta 译名普利文·古塔国籍印度原文出处International Journal on Computer Science and Engineering 使用XML,Spring和struts以MVC为设计模式的多分布式应用程序框架摘要:模型-视图-控制器(MVC)是一个基本的设计模式,用来分离用户界面与业务的逻辑。
近些年来,应用程序的规模越来越大,而MVC设计模式可以弱耦合不同应用层的程序。
本文提出了一种基于J2EE平台上的网络,它扩展了MVC、XML 的应用程序框架,易于维护。
这是一个包括表示层、业务层、数据持久层和数据库层的多系统层,由于其代码的具有独立性,可维护性和可重用性大大提升。
在本文中,我们使用MVC实现spring和struts框架。
我们的研究显示,应用多个框架设计应用程序时,使用MVC概念能使应用程序转变为更容易、较单一的框架。
关键字:MVC,Spring,XML一介绍近些年来,web是非常复杂的问题。
因为公司和组织越来越多,不同类型的通讯设备也越来越多,特别当业务要求应用程序使用web和许多通信设备的时候,网络编程的性能越加重要。
所以在互联网上,在增加负载的数据的同时,我们必须照顾体系结构的问题。
让我们简要讨论到目前为止MVC的研究。
1.1没有MVC在web开发的初始阶段,页面被用来设计html,其中Html是纯文本。
这是第一个在互联网上工作的标记语言。
今天仍然是基于块的所有互联网的编程语言。
用户必须实现与静态页面交互,信息手动写在页面时必须改变。
随着时间增长,语言和页面可以按照用户需求相互作用,页面也会有相应的变化。
1.2 MVC模式一第一个重大变化是由于架构的流行,引入了MVC模式。
这种具有控制演示、业务逻辑和流程的架构是以页面为中心,以Java语言为服务器的页面程序。
逻辑就是在这个模型概念中介绍的。
Java bean和scriptlet、表达式等业务逻辑都是以硬性编码的形式存在的。
页面里的所有代码都是用jsp编写的。
让我们假设,我们想传输基于我们收到数据时的jsp的情况。
图一页面导航MVC-1框架1.3 MVC模式二模型1架构能够解决一些网络和网络编程的问题,但仍有很多东西丢失。
它是集中jsp页面的导航,从而能进一步发展的体系结构的观点。
在这个过程中未来发展是Model 2架构。
这个解决了一起使用Servlet和JSP的问题。
能够服务处理初始请求和部分处理数据。
它设置bean然后结果转发到一个jsp页面。
Servlet决定从列表中显示一个页面到页面。
图二MVC-2框架在这个模型中2架构的JSP页面仅用于演示目的。
业务逻辑已经从页面删除。
这使页面更容易表示并且轻、重量级页面也很容易在互联网上显示。
在这个模型中所有的控制和应用程序逻辑都由Servlet处理。
Servlet是用java 编程语言编写的,所以它也是容易处理的Servlet的一部分。
在这种情况下的服务成为全面完整的应用程序,它已成为应用程序的中心点。
在model 2架构中,Servlet成为所有常见任务的“看门人”。
它提供了诸多公共服务,如身份验证、授权、错误控制和应用程序的循环。
此体系结构解决了大部分的问题。
但仍有许多新的问题出现在这个应用架构。
二应用架构与多个框架在越来越多的网络和互联网领域,应用程序的需求正在增长。
单独的一个框架是不能处理应用程序的体系结构的需求的。
满足潮流要求的应用程序有必要设计一个完整的框架体系结构。
Struts框架设计和web应用程序的前端控制开发有着密不可分的联系。
它为用户提供了各种功能交互的应用程序。
它也遵循MVC 2设计特点。
Spring框架是用来设计处理各种任务的。
Spring的工作是基于互联网的应用程序。
它遵循的原则MVC 2。
同时使用Struts和spring框架在单个应用程序应使用MVC设计主体,这样我们可以提高应用程序的性能。
Struts框架包括三个主要模块,简要描述如下:图三Struts框架第一个是使用块控制,以用来表示完整的模型的一部分。
它包含自定义标记库,为我们编写JSP的特定应用程序提供了国际化资源文件。
第二块是代表控制器。
它是导航的完整应用程序,包含XML配置文件和含标签的导航路径。
第三块是模型。
这部分工作主要是分析业务逻辑,抓取和存储数据到数据库中。
它包含Java bean、Enterprise和数据库。
下图显示了struts框架中的组件工作。
图一struts框架组件Struts中的MVC在Spring框架中,MVC的主要表现在以下三个部分。
控制器,Servlet控制器(部分);Java服务器页面(视图部件);应用程序业务逻辑,应用程序的形式(模型)。
Spring组件在Spring里,我们也遵循MVC的原则。
它被设计为基于互联网和桌面的应用程序。
Spring包含三个核心组件。
1,控制器:处理导航逻辑和交互与服务的业务逻辑层2,模型:控制器和视图之间的联系,包含由控制器渲染的视图和其所需的数据3,视图:根据用户请求,呈现从模型中获取数据。
spring MVC核心组件如下。
1.DispatcherServlet:Spring的前端控制器实现。
它是控制器进行交互的第一个请求。
我们也可以说它是一个Servlet的实现。
它控制应用程序的完整流程。
2.控制器:用户创建的组件来处理请求封装导航逻辑代表服务对象的业务逻辑。
3.视图:负责渲染输出。
不同的视图可以在查看设备的基础上,选择不同类型的通信设备和输出结果。
ModelAndView:ModelAndView是spring框架的核心部分。
它实现了应用程序的业务逻辑。
它是由控制器控制。
每当它执行时,都会存储业务逻辑和与之关联的视图。
ViewResolver:根据返回的结果,输出显示收到的ModelAndView。
由逻辑视图名称映射到实际的视图是由它实现的。
这部分标识时实现输出媒体是什么,以及如何显示该媒体。
HandlerMapping:该接口使用DispatcherServlet传入的请求映射到单个控制器。
它标识请求,并调用相应的处理程序提供的服务。
下面的图显示了模型的作用。
在这个dispatcher Servlet应用程序的入口点,Struts部分作为框架,而dispatcher Servlet用于发送请求。
Servlet决定处理程序。
那么它将调用控制器,控制器执行ModelAndView。
图5 序列流应用程序的spring框架三提出的方法这种方法的组合应用为两个框架,struts和spring应用程序开发打下了基础。
序列图的组合应用程序解释如上所述,这是应用程序的主要驱动力。
要想使用这种方法,web应用程序的基本知识是必要的。
我们已经测试了上述概念,找出它优点,上述体系结构的主要优点如下:1.它将提供一个非常简洁的部分之间的行动,行动的形式,控制器,处理data we received from the input.1.3 MVC Model 2 :The model 1 architecture was able to solve some of the problem of the web and internet programming but still there were a lot of things missing from it. It was centered on the navigation of the jsp pages so there was the scope of the further development in the architecture point of view. During this process the next development was the Model 2 architecture. This problem was solved using the Servlet and JSP together. The Servest handles the Initial request and partially process the data. It set up the beans then forward the result to the one of the jsp page. The Servlet decide the one of the page to be displayed from the list of pages.In this Model 2 architecture the JSP Pages were used to Presentation purpose only. The Business logic has been removed from the page. This makes the pages easier to represent and light weight pages which were easy to display on the internet.In this model all Control and application logic were handled by the Servlet. The Servlet was written in the java programming language. So it was also easier to handlethe programming part of the Servlet. In this scenario the Servest becomes the power full for the complete application and It has emerged as the center point for the application.In the model 2 architecture the Servlet becomes the gatekeeper for the all common tasks. It provides the common services like authentication, authorization, error control and follow of the application. This architecture have solved the most of the problems. But still there were many new issues emerged while applying this architecture.II. APPLYING ARCHITECTURE WITH MULTIPLE FRAMEWORKSWeb and Internet is ever growing area and the demands for the applications are growing. A single framework is not capable to handle the architecture of the application. To meet the currents requirement of the applications it’s necessary to design a architecture to implement the frameworks.Struts framework have been designed and developed for the front end control of the web applications. It provides the various features for the applications that interact to the users. It also follows the MVC 2 design features.Spring Framework is the designed to handle the various tasks. The spring work for the desktop and internet based applications also. It follows the principals of the MVC 2. The simultaneous use of the Struts and spring frameworks in the single application with the applying the MVC Design principals so that we can Improve the performance of the applications.Struts Framework consists of three major blocks, Described in brief as follows:First is The View Block which controls the presentation part of the complete model. This contains following JSP files which you write for your specific application Set of JSP custom tag libraries Resource filesfor internationalization.Second Block is representing the Controller. This is for navigation the complete application. This contains XML configuration files; it contains the tags for the navigation of the paths.Third Block is the Model. This part do the work of the Business Logic, Fetching and storing data to the database.This contains following Java Beans Enterprise Java Beans Database. Following figure shows the working of the components in the struts framework.MVC in StrutsThe major three parts of the MVC are as follows in the spring framework. Servlet controller (Controller Part) Java Server Pages or any other presentation technology (View Part) Application Business Logic: in the form of whatever suits the application (Model Part).SpringComponents.In the spring we also follows the principals of the MVC . It has been designed more for the desktop and internet based applications. Spring consist of three core collaborating components. 1. Controller: Handles navigation logic and interacts with the Service tier for business logic 2. Model: The contract between the Controller and the View Contains the data needed to render the View Populated by the Controller 3. View: Renders the response to the request Pulls data from the model.Core components in the spring MVC are as follows.DispatcherServlet: Spring’s Front Controller implemen tation. It is the first controller which interacts to the requests. We can also say it is an implementation of the Servlet. It controls the complete flow of the application.2. Controller: User created component for handling requests encapsulatesnavigation logic delegates to the service objects for business logic.3.View: Responsible for rendering output. Different views can be selected for the different types of output bases on the results and the viewing device, communication devices.4.ModelAndView: ModelAndView is the core part of the spring framework. It implements the business logic of the application. It is controlled by the controller. It stores the business logic and the view associated with it. Whenever it is executed it will the data with the name of the view.5. ViewResolver: How the output is to be displayed depends on the result received from ModelAndView. It is used to map logical view names to actual view implementations. This part identifies and implement what is the output media and how to display it.6. HandlerMapping: Strategy interface used by DispatcherServlet for mapping incoming requests to individual Controllers. It identifies the request and calls the respective handler to provide the services.The following figure shows how the model will work. In this the dispatcher Servlet is the entry point for the application. The Struts parts do it’s work and send the request to the dispatcher Servlet. The Servlet decides the handler. Then it will call to the controller. Controller will execute the ModelAndView.III. PROPOSED METHODOLOGYThis approach is based a combination of applying the two framework struts and spring for the application development. The sequence diagram for the combined application is explained as above, which is the main driving force for the application. This approach assumes that basic knowledge of web applications is essential. We have tested the above concepts and find out it successfully. Major benefits注:1. 指导教师对译文进行评阅时应注意以下几个方面:①翻译的外文文献与毕业设计(论文)的主题是否高度相关,并作为外文参考文献列入毕业设计(论文)的参考文献;②翻译的外文文献字数是否达到规定数量(3 000字以上);③译文语言是否准确、通顺、具有参考价值。