首页 外文文献-基于MVC的Struts框架

外文文献-基于MVC的Struts框架

举报
开通vip

外文文献-基于MVC的Struts框架外文文献-基于MVC的Struts框架 毕业设计说明书 英文文献及中文翻译 目 录 1 Struts Framework Based on MVC ............................................................................................................ 1 2 Hibernate Framework Based on ORM ......................................

外文文献-基于MVC的Struts框架
外文文献-基于MVC的Struts框架 毕业 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 说明书 英文文献及中文翻译 目 录 1 Struts Framework Based on MVC ............................................................................................................ 1 2 Hibernate Framework Based on ORM ...................................................................................................... 3 2.1 Introduction of Hibernate ............................................................................................................... 3 2.2 Principle of Hibernate .................................................................................................................... 4 3 The Integration of Struts and Hibernate .................................................................................................... 5 3.1 Flow of Framework ........................................................................................................................ 6 3.2 Systematic Structure of the Integration Framework ...................................................................... 6 1 基于MVC的Struts框架 ........................................................................................................................ 8 2 基于ORM的Hibernate框架 ................................................................................................................ 10 2.1 Hibernate介绍 ................................................................................................................................ 10 2.2 Hibernate标准 .................................................................................................................................11 3 Struts和Hibernate的整合 ..................................................................................................................... 12 3.1 框架的工作流程............................................................................................................................ 12 3.2整合框架的系统结构 ..................................................................................................................... 13 第 ? 页 共 ? 页 1 Struts Framework Based on MVC In the traditional Web application, Java Server Pages(JSP) pages are responsible for handling all things, for example, receiving requests, executing business logics, choosing the next page. These complicated things may lead to chaos of JSP pages’ codes and be harmful for the extension and maintenance of pages. The Model-View-Controller (MVC) mode separates the programming codes into three different areas, which has solved the above problem. MVC can realize J2EE application system's stratification and the loose coupling of three layers or multilayer, and it is a realization way of orienting dynamic content. The MVC mode divides application into three core components of Model, View and Controller. Struts is a realization of MVC. It is an open source Web application framework and uses Servlet and JSP marks that belong to the J2EE norm as a part of the realization. Struts inherits MVC characteristics and realizes some corresponding changes and extension according to J2EE traits. Struts separates Java codes of JSP by Java Bean and Action class to be the MVC mode, transmits data among the three partitions of Model, View and Controller, demonstrates the connection between various classes and JSP pages by configuration files finally and it intends to realize the separation of presentation layer, business layer and data layer. The Struts structure is shown in Figure 1. The Model contains the business logic that exchanges data with a persistence layer. The View is in charge of producing what is directly visible to the user, e.g. web pages. The Controller is the layer that receives requests from clients, determines what business logic takes place and where to go next. In the Struts framework, the Model uses Java classes for the business logic. The View can be implemented with JSP and the Tag lib of Struts. The Controller is a J2EE component known as Servlet, more specifically an ActionServlet object, which determines what or when logic gets executed and where the control should get directed. DispatchHttpRequest Business Logic(Action) Controller ActionServletEvent Forward ClientStruts-config.xml(Browser) Update HttpRespose ModelGet View(JSP) (Application State) Struts-TaglibApplication Resource Figure 1. Struts structure 2 Hibernate Framework Based on ORM Working with both the object-oriented software and the relational database is a complicated task with Java Database Connectivity (JDBC) because there is mismatch between how data is represented in objects versus relational database. So with JDBC, developers have to write pure the Structured Query Languag (SQL) statements to map an object model's data representation to a relational data model and its corresponding database schema. 2.1 Introduction of Hibernate Hibernate is a flexible and powerful Object-Relational Mapping (ORM) solution to map Java classes to database tables. It is a powerful, high performance object-relational persistence and query service. Hibernate allows developers to express queries in its own portable SQL extension (Hibernate Query Language (HQL))[3], as well as in native SQL, or with an object-oriented criteria and example Application Programming Interface(API). Hibernate itself takes care of this mapping using XML files so developers don’t need to write code for this. Hibernate is an open source and it is free to use for both development and production deployments, which is a bridge between Java application and relational database and takes charge of mapping between Java objects and relational data. The inside of Hibernate packs the operation of accessing database by JDBC, which provides API of object-oriented database access to upper layer application. So developers can use the object programming thought to operate database sufficiently, caring for the bottom database structure unnecessarily. Hibernate relieves the developer from 95 percent of common data persistence related programming tasks, compared to manual coding with SQL and the JDBC API[4]. And it can integrate various Web server or application server, and nearly support all popular databases server. 2.2 Principle of Hibernate Application Persistent Objects Hibernate Hibernate.propertiesXML.Mapping Database Figure 2. Hibernate systematic structure As shown in figure 2, Hibernate lies in the middle layer that is between application and database .In the provided persistent service, Hibernate maps class to rows of datasheet by properties and mapping files of class (mapping.xml) itself. Application interacts with database by Persitstent Object (PO) to handle data directly. 3 The Integration of Struts and Hibernate In the open source frameworks, for the presentation part, Tapestry has the powerful and natural combination of pages, its document is too conceptional to benefit programming. And its learning curve was too steep and so on. For the logic part, Spring has a good integration function, but there is a lack of public controller. And EJB depends on the EJB containers, at the same time, it is realized complicatedly. While Struts has been applied extensively because of its advantages. At present, most of systems apply the relational databases mainly, while Java is an object-oriented language essentially. In Model part of Struts framework application, using SQL and JDBC to operate databases when storing and fetching objects reduces programming efficiency and the systematic maintainability. Traditional J2EE-based application applies heavyweight framework based on EJB that adapts to the large enterprise development, while development and debugging by EJB container need to consume a plenty of time and high price. EJB3 improves the disadvantages of original EJB, but its application is not mature yet. Hibernate can substitute Container-Managed Persistence (CMP) to accomplish heavy responsibility of permanence in J2EE framework of applying EJB.In a word, Hibernate can resolve the difficulties coming from using traditional CMP, JDBC and Data Access Object(DAO) in a technological development. For reducing the coupling of code and raising systematic development efficiency, this paper suggests J2EE application development tactics based on Struts and Hibernate. The Struts design shows the MVC framework sufficiently, which all control flows need a configuration file (Struts-config.xml) to manage, and which is convenient to maintain. The integration of Struts and Hibernate is that Hibernate solves the model layer of Struts, which makes developers operate Java objects instead of database. The integration shows the object-oriented thought sufficiently and solves some problems of the database operation in traditional J2EE well. 3.1 Flow of Framework The flow of integration framework based on Struts and Hibernate is shown in Figure 3. At first, users send Http requests by Browser, then Http requests are accepted by ActionServlet of the control component in business layer, then gave to RequestProcessor which gets corresponding Action from ActionMapping by request URL[3]. Besides, ActionForm packs JSP pages, which can make a checking to data of datasheet if it is needed, send back ActionErrors to visual pages if there are mistakes and transfer the data of pages to Action if it passes validation. Request Processor transfers the “execute” method of Action and the method transfers the business logic module. Hibernate accomplishes interaction of databases and JavaBean. The operation of processing business logic interacts with database by data permanence layer and field object layer. The “execute” method of Action will return ActionForward objects that are accepted by ActionServlet after executing. 3.2 Systematic Structure of the Integration Framework The EIS layer of the multi-layer J2EE systematic structure can be partitioned into the data permanence layer and the data resource layer. It means a system can be divided into five layers as a whole. Client Layer: This layer runs in the Browser of users’ machines and handles interaction with users, transmits and shows messages to users. J2EE platform supports different type users including HTML users, Java Applets, Java application, etc. Presentation Layer: This layer works in J2EE Web container, produces the systematic representation logic, handles users’ requests and makes the responses. The entire Web is built on Struts framework, in which the View component is composed of JSP/HTML pages whose data is expressed by ActionForm Bean, the Controller component is composed of ActionServlet united Struts-config.xml and Action Classes, and the Model component is realized by business logic layer. Business Logic Layer: This layer accomplishes the required business of system, provides the required business method to presentation layer. It can receive data from client programs and save them to the storage equipment after proper disposal, read data from the data storage equipment, then send them out to client programs. This layer is composed of Business Objects (BO) such as JavaBean and session EJB. Request Presentation JSP(Taglib)pages dataBrowserlayerResponseActionForwardRelational Data databaseverification Mapping Permanence ActionServletJavaBeanActionlayer(ActionMapping)EJBHibernatefill dataActionForwardActionFormBusiness logic layer Figure 3. Flow chart of the integration framework based on Struts and Hibernate 1 基于MVC的Struts框架 在传统的Web应用程序,Java服务器页面(JSP)页面负责处理所有的事情,例如,接收请求,执行业务逻辑,选择下一个页面。这些复杂的事情,可能会导致混乱JSP 页面编码和有害的扩展和维护的JSP页面。模型--视图--控制器(MVC)模式编程代码分离成三个不同的区域,它已经解决了上述问题。 MVC可以实现J2EE应用程序的系统的分层和三层或多层的松散耦合,它是一个实现的定向动态内容的方式。 MVC模式把应用程序分成三个核心部件的模型,视图和控制器。 Struts是一个MVC实现。它是一个开源Web应用框架,使用Servlet和JSP标记属于J2EE规范的一部分实现。的Struts继承了MVC的特点和根据J2EE性状,实现一些相应的变化和扩展。 Struts的分离JSP的Java代码的Java Bean和Action类是MVC模式,数据传输三者间的分区模型,视图和控制器,演示各种类和JSP页面之间的连接配置文件,终于和它打算实现 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 现层,业务层和数据层的分离。 Struts的结构示于图1。 该模型包含业务逻辑交换数据持久层。查看是负责生产的,什么是直接对用户可见,例如网页。控制器层,接收来自客户端的请求,决定哪些业务逻辑需要的地方,下一站去哪里。在Struts框架中,模型用业务逻辑的Java类。 JSP和Taglib是Struts的视图可以实现。该控制器是被称为Servlet的J2EE组件,更具体一个ActionServlet的对象,这就决定什么逻辑被执行时,应该得到控制。 第 1 页 共 6 页 分发HttpRequest 控制 ActionServlet处理Action层请求 重定向 客户端浏览器配置文件Struts-config.xml 更新 HttpRespose Get方式 模式状态 视图(JSP) (Application State) Struts标签应用资源 图1.Struts结构 第 2 页 共 6 页 2 基于ORM的Hibernate框架 Java数据库连接(JDBC),面向对象的软件和关系数据库的工作是一项复杂的任务,因为数据是如何表示的对象与关系数据库之间存在不匹配。因此,使用JDBC,开发人员必须写纯结构化查询语言开发(SQL)语句对象模型的映射数据表示关系数据模型及其相应的数据库架构。 2.1 Hibernate介绍 Hibernate是一个灵活和强大的对象--关系映射(ORM)的解决方案,Java类映射到数据库表。这是一个强大的,高性能的对象关系持久性和查询服务。Hibernate允许开发人员在其自己的便携式SQL扩展来表达查询(Hibernate查询语言(HQL)),以及在本地的SQL,或面向对象的标准和示例应用程序编程接口(API)。Hibernate自身需要照顾这个映射使用XML文件,以便开发人员不需要编写代码。 Hibernate是一个开放源代码和用于开发和生产部署,这是一个桥梁Java应用程序关系数据库之间和负责的Java对象和关系数据之间的映射,它是免费的。里面的Hibernate包JDBC,它提供了面向对象的数据库访问到上层应用的API访问数据库的操作。因此,开发人员可以使用对象编程思想,充分操作数据如图2所示,休眠在于中间层和应用程序之间提供了持续的服务,Hibernate的映射类类的属性和映射文件(mapping.xml中)本身的数据表行database。应用程序与数据库由持久化对象(PO)直接处理数据。库,关怀不必要底层数据库结构。 Hibernate的减轻了开发人员常见的数据持久化相关的编程任务的95,,比手动编码的SQL和JDBC API。它可以集成各种Web服务器或应用服务器,几乎支持所有流行的数据库服务器。 第 3 页 共 6 页 2.2 Hibernate标准 应用 持久化对象 Hibernate Hibernate 属性XML映射文件 数据库 图2.Hibernate系统结构 如图2所示,休眠在于中间层和应用程序之间提供了持续的服务,Hibernate的映射类属性和映射文件(mapping.xml中)本身的数据表行database。应用程序与数据库由持久化对象(PO)直接处理数据。 第 4 页 共 6 页 3 Struts和Hibernate的整合 在开源框架,用于演示的一部分,代理路由算法具有强大能自然的和网页结合,其文件是太概念性受益编程的。其学习曲线太陡等。Spring的逻辑部分,具有良好的整合功能,但是缺乏公众控制器。和EJB 依赖于EJB容器,在同一时间,实现复杂。虽然Struts已经被广泛应用,因为它的优势。 目前,大多数的系统关系数据库应用为主,而Java是一种面向对象的语言本质。在Struts框架的应用程序,使用SQL和JDBC来操作数据库存储和获取对象的模型的一部分,降低了编程的效率和保持了基于EJB的系统性,基于J2EE的应用程序适用于重量级大型企业的发展,同时开发和调试由EJB容器需要消耗大量的时间和高昂的价格。 EJB3提高原始EJB的缺点,但其应用还不够成熟。 Hibernate可以替代容器管理持久性(CMP)来完成持久的重任,在J2EE架构中应用EJB 。总之,Hibernate可以解决使用传统的CMP,JDBC和数据访问对象(DAO)在科技的发展的困难时候。为了减少代码的耦合,提高系统的开发效率,本文提出了基于Struts和Hibernate的J2EE应用程序的开发策略。 Struts的设计充分显示了MVC的框架,所有的控制流量需要一个配置文件(struts-config.xml中)来管理,这是维护方便。 Struts和Hibernate的集成Hibernate的解决了模型层,Struts中,这使得开发Java对象,而不是数据库。整合显示了面向对象的思想,充分解决了一些问题,在传统的J2EE以及对数据库的操作。 3.1 框架的工作流程 请求进程的得到相应的Action,ActionMapping的请求URL。 ActionForm的包JSP页面,它可以使一个检查数据表的数据,如果它是必要的,此外,发回的ActionErrors视觉的页面,如果有错误和行动,如果它通过验证页面的数据传输。 请求进程的行动纲领“执行”的方法转移的方法转移的业务逻辑模块。 Hibernate的数据库和JavaBean实现互动。处理业务逻辑与数据库中的数据持久层和领域对象层交互的操作。“执行”行动的方法,将返回的ActionForward对象的ActionServlet执行后所接受的。 第 5 页 共 6 页 3.2整合框架的系统结构 在EIS层的多层J2EE系统结构可以被划分为数据持久层[7]和数据资源层。这意味着,一个系统可以被分为5个层作为一个整体。 客户层:该层运行在用户的计算机上的浏览器的用户,传输和显示给用户的消息和处理互动。 J2EE平台支持不同类型的用户,包括HTML用户,Java小程序,Java应用程序等。 表示层:此层工作在J2EE的Web容器,生产系统表述逻辑,处理用户的请求,并作出响应。整个网络是建立在Struts框架中,视图组件由JSP / HTML页面的数据所表达的ActionForm Bean的控制器组件是由ActionServlet的团结的Struts-config.xml和动作类,和标准组件实现业务逻辑层。 商业逻辑层:这一层实现所需的业务系统,表示层提供所需的业务方法。它可以接收来自客户端程序和妥善处置后,将它们保存到存储设备,数据存储设备读取数据,然后将其发送到客户端程序。这层是由如JavaBean和会话EJB的业务对象(BO)。 请求 浏览器JSP标签响应网持久化层数据页关联的数据库数 据 Mapping ActionServletJavaBean持久化层动作动作映射容器Hibernate 数填动作转向据出控制业务逻辑动作 图3.基于Struts +Hibernate整合后的流程图 第 6 页 共 6 页
本文档为【外文文献-基于MVC的Struts框架】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_014457
暂无简介~
格式:doc
大小:42KB
软件:Word
页数:14
分类:企业经营
上传时间:2017-09-19
浏览量:39