Spring 的 web MVC 构架模式外文翻译资料

 2022-12-19 05:12

Springs web MVC architecture pattern

Juergen Hoeller

1. Introduction: Springs application architecture.When you first see and touch the Spring framework, you will definitely think in your heart; 'Oh, no, this is another Web architecture.' This article will point out that the Spring framework is not a special web framework, but a generic lightweight application framework, an application framework supported by a dedicated network. And it will tell you that the Spring framework is clearly different from other lightweight application frameworks, which will focus on web support, with a clear distinction between struts and webwork. In contrast to struts and webwork, the Spring framework is an application framework that serves all levels: providing the beans configuration base, AOP support, JDBC extraction framework, abstract transaction support, and so on. It has a very significant feature: at some level, if you dont need Spring support, it has a very significant feature: At some level, if you dont need Spring support, you can not use the Spring framework. Class (class), only the function of a certain part of it. From its design philosophy, you can see that the Spring framework helps you achieve a true separation of the logical and web layers: for example, a validation application can be implemented without relying on controllers. The goal is better reuse and easy testing: this cant be achieved by relying too much on unnecessary containers and frameworks. Of course, Springs own web support and the usual framework patterns are meticulous and complete. However, Spring is a great alternative to struts, webwork or other web solutions. For web support in Spring or in different places, Spring allows you to create an intermediate layer in the web container to set up reuse of your business logic in a test environment or a standard standalone application. There is also a J2EE environment that allows you to rely on the services provided by the container, such as JTA, EJB support. A web application with a good framework can run on any container, such as Tomcat or Resin. Its worth noting that Spring is not a competitive relationship with existing solutions. We encourage the integration of standard technologies such as Servlet, JSP, JTA, JNDI, JDBC and JDO, and other very matching tools such as Hibernate, Velocity, Log4J, and Cauchorsquo;s Hessian/Burlap. The design of this framework is that when your application needs to be improved, you will be able to make some technical choices: for example, if you need distributed transaction processing, you may need to implement JTA with the Spring Frameworks JTA Transaction Manager. service. Or, use DataSourceTranscactionM anager or HibernateTransction Manager to achieve a wonderfully perfect single database exchange.

2, Web MVC: the design idea of the Spring web framework.The Spring Network Framework configures action mappings configurable handlers, shows resolution, localization, and template integration around the servlet dispatching request operations - DispatcherServlet dispatch request handlers, configurable handler maps, resolutions, resolutions, and locales and topics Designed. The default action is a very simple controller interface, which simply provides a 'ModelAndView handleRequest(request request, response response)' method. This can already be applied to an applications program controller, but if you want to include multiple levels of control, Abstract Controlerr , AbstractCommand Controllers ,The MultiAction Controllers , SimpleForm Controllers , and AbstractWizardForm Controller will help you with the completion, and the application controller will represent those subsystems that are usually subclasses. Note that you can choose an appropriate base class: if you dont have a web form, you dont have to use Form Controller. This is the biggest difference from Struts. You can manipulate any object as a command or form object: This eliminates the need for interface tools or a base class driver. Springs data binding is very flexible. For example, for a validation error that treats a type mismatch, he describes an input mechanism with a validation error within the scope of the application, but not a system error. So in your form object you dont need to copy the properties of the Spring Framework of your business object as a string form object, you can handle invalid commits, or put strings. Instead, it is usually more directly tied to your business object. This is another major difference. Struts is built on the need for base class actions and ActionForms - for any type of action. You only need to manipulate the subtasks that are in error, or convert the spring framework appropriately. In other words, he can usually bind your business objects in good bytes. This is also one of the main differences from Struts around the request base class Action and ActionForm (each action action type). In contrast to WebWork, the Spring framework is more of an object role: the Spring framework supports the concept of a controller, an optional action command or form object, and gets the data and passes it to the views schema. This mode usually contains command and form objects, but sometimes it also contains arbitrary reference data. In other words, instead a webwork aciton combines all of these roles into separate objects. The network system does not allow you to use existing business objects as part of your f form, but only generate bean properties for the respective Action action classes. Finally, the aciotn operation instance of the same operation request is assigned and formed into a population cluster in a view. Therefore, reference data needs to be mimicked as a bean property of the action. These can be said to be too many roles in an object. However, the reference data also needs to be simulated as an attribute of the action. There are too many roles in a class that are worth discussing. About views: The Spring frameworks view scheme i

剩余内容已隐藏,支付完成后下载完整资料


Spring 的 web MVC 构架模式

Juergen Hoeller

1、 介绍: Spring 的应用构架

当你第一次看到并接触 Spring 框架的时候,你一定会在心里想到; “哦哦, 不不,这又是另一种 Web 构架”。这篇文章将会指出 Spring 框架不是什么特殊 的 web 框架, 而是一个通用的轻量级的应用程序框架,在专用网络支持下的应用 程序框架。并且它会告诉你 Spring 框架明显区别于其他轻量级 application framework,它将专注于 web 的支持,与 struts 和 webwork 有着明显的区别。 在和 struts 和 webwork 的对比上之中,Spring 框架是一个服务于所有层面 上的 application framework:提供了 bean 的配置基础,AOP 的支持,JDBC 的 提取框架,抽象事务支持,等等诸如此类。它有一个非常显著的特点:在某个层面上如果你不需要 Spring 的支持, 它有一个非常显著的特点: 在某个层面上如果你不需要 Spring 的支持,你就可以不使用 Spring 框架的 class(类),只使用它的某一部分的功能。 从它的设计理念, 你可以看到 Spring 框架帮助你实现了真正的逻辑层和 web 层的成功分离:例如:一个校验应用将不用依靠 controllers,就可以实现。这 样的目标是更好的重用和易测:过分依靠不必要的容器和框架将不能实现这一 点。 当然,Spring 的自己本身的 web 支持和通常框架模式的细致完整。然而, Spring 替换 struts, webwork 或者其他的 web 方案非常的容易。 这个对于 Spring 的 web 支持或者不同的地方,Spring 允许你在 web 容器里面建立一个中间层, 在测试环境或者标准独立的应用里面来设置重用你的商务逻辑。 还有就是在 J2EE 环境里面,可以让你你的商务逻辑不必依靠容器提供的服 务,就比如像 JTA,EJB 的支持。良好的框架的一个 web 应用是可以运行在任何 容器上,就比如,Tomcat 或者 Resin 这些容器。值得注意的事,Spring 不是和 已经存在的解决方案进行竞争的关系。我们鼓励结合标准的技术,如 Servlet, JSP,JTA,JNDI,JDBC 和 JDO,和其他非常匹配的工具,比方如 Hibernate, Velocity,Log4J,和 Cauchorsquo;s Hessian/Burlap 这类工具。这个框架的设计思想 是你的应用处在需要改良的时候,你将可以对其做一些技术的选择:例如,如果 你需要分布式事务处理,你可能需要用 Spring 框架的 JTA Transaction Manager 来 实 现 JTA 服 务 。 或 者 , 用 DataSourceTranscactionM anager 或 者 HibernateTransction Manager 来实现美妙完美的单个数据库交换。

2、 Web MVC:Spring web 框架的设计思想

Spring 网 络 框 架 通 过 配 置 操 作 mappings 可 配 置 的 处 理 程 序 , 展 示 resolution , 本 地 化 和 模 板 集 成 围 绕 着 分 派 请 求 操 作 的 servlet -DispatcherServlet 分派请求处理程序,可配置的处理程序映射,决议,决议 和语言环境和主题设计的。 缺省的操作是一个非常简单的控制器接口,他只是提 供了一个“ModelAndView handleRequest(request 请求,response 响应)”的 方法。这已经可以将它应用于一个应用的程序控制器,但是,如果你想包含多个 层 次 的 控 制 , Abstract Controlerr , AbstractCommand Controllers,MultiAction Controllers ,SimpleForm Controllers , AbstractWizardForm Controller 将帮助你完成,应用程序控制器将代表那些子系统通常是子类。注 意,你可以选择一个适当的基类:如果你没有 web form(网络形式),你就不必 用 Form Controller。这便就是和 Struts 最大的不同区别了。你可以把任何物 体作为命令或者形式对象来操作任何对象: 这就可以不需要接口工具或者一个基 础类的驱动。Spring 的数据绑定是非常的高度灵活的。举例来说,对待类型不 匹配的验证错误, 他描述了具有在应用范围内的校验错误的输入机制,但不是系 统错误。 所以在你的形式对象里面你大可不需要复制你的业务对象的 Spring 框架中 的属性作为字符串表单对象,就能够处理无效的提交,或将字符串。相反,它通常 比直接绑定到您的业务对象。这是另一个主要区别 Struts 是建立在需要基类行 动和 ActionForm——对任何类型的行动。只需要操作出错的子任务,或者适当 的转换 spring 框架。换句话来说,他通常可以很好的字节绑定你的业务对象。 这也是和 Struts 围绕请求基础类 Action 和 ActionForm (每个 action 操作类型) 建立主要的不同之一。 对比 WebWork(网络系统),Spring 框架更多的区别在于对象角色:Spring 框架支持控制器的概念, 一个可选的操作命令或者表单对象,得到数据并传递给 视图的模式这个模型。 这个模式通常包含命令和表单对象,但有时也包含任意的 参考数据。换句话来说,相反一个 webwork aciton(网络系统动作) 联合了所 有这些角色到单独的对象中。网络系统不允许你用已经存在的业务对象作为你 f 表单的一部分,但是只生成各自相关 Action 操作类的 bean 属性。 最后,相同的操作请求的 aciotn 操作实例在一个视图里面获得赋值和形成 人口集群。 因此,引用数据需要模仿作为行动的 bean 属性。这些可以说是太多的 角色在一个对象中。 然而,参考数据也需要作为 action 的属性被模拟。一个类里面有太多的角 色是值得讨论的。 关于视图:Spring 框架的视图方案非常的灵活。甚至可以编写一个视图控 制器实现通过 respongse 返回 ModelAndview 对象的 null 值, 就可以直接写到一 个视图。 在通常的状况下,一个 ModelAndView 实例结合了一个 view(视图名称)和 一个 model Map(模型地图),包含了 bean 名称和相应的通讯对象(像命令或 者形式,参考数据,等等)。视图名称解析是非常高端的配置,不是通过 bean 名称 ,一个 propertiese 文件,就是通过你自己的 ViewResolver 来实现的。 这个抽象的 model Map(模型映射)允许你在视图层面完成提取视图,没有任何的 争辩麻烦:JSP ,速度,或者其他,每一种渲染器都可以直接完整集成使用。这 个 model Map (模型映射) 还可以简单转化得到适当的格式化数据的转换, 像 JSP 请求属性或者 Velocity 模板模式。

3、 集成:用 Spring 一个不同 web 框架

许多开发团队将为他们已有的项目或者新的项目已经获得的期限和工具进 行投资。这里没有像 Struts 那样大量的图书和工具,但是同样我们又大量的拥 有 Spring 开发技巧的开发人员。然而,如果你愿意生活在 Strust 的构架瑕疵中

的话,它仍然是一种可行的选择 web 层而他将会是你在 web 层开发不错的选择。 当然,其他应用也是一样。 如果你不想 Spring 框架的 web MVC,但是又想借用 Spring 框架嫁接其他的 解决方案,你可以非常简单的通过 Spring 框架来继承你自己的 web 框架。你可 以非常简单的通过 Context LoaderListener 启动一个 Spring root application context,并且,通过 Struts 或者网络系统的 action,利用 Servletcontext 属性(或者 Spring 的 helper 方法)存取它。值得注意的事,这里没有任何 的”plugings”被调用,因此没有专门的集成:来自 web 层的视图,你可以简单 的将 Spring 作为一个管理 application context 实例入口点的类库。 所有你注册的 bean 和 Spring 框架的服务都可以在不需要 Spring 框架的 web MVC 的情况下都可以被你轻松掌握。Spring 不是和 Struts,Webwork 这些应用进 行竞争,他将作为一个纯 web 框架应用于很多领域,它解决了许多领域,纯 web 框架不从 bean 配置数据访问和事务处理。因为它不需要配置数据存储和事务操 作。所以,你可以利用 Spring 提供的中间层和数据存储层来丰富你的应用,甚 至,你只是想用 JDBC 或者 Hibernate 进行事务抽象。

4、 特点核对列表

如果聚焦于 web 支持,Spring 框架的一些显著特点是:清楚的角色分离: controller , validator , command object , form object , model object 和 Dispatcher Servlet,handler mapping vs view resolver,等等。 强大而且直接简单的框架和作为 javaBean 的应用配置,包括简单的参照和 应用程序上下文引用内容,例如,从 web 控制器到业务对象和数据校验器。 适应性,外挂:无论使用什么样的控制器你都需要得到替代 Action/ActionForm 所做的每件事情的方案(简单,命令, form ,范例,多重 action,或者定制一个)重用业务逻辑代码,而不是源于 Action/ ActionForm 一切。不需要复制: 你可以用已经有的业务逻辑对象作为命令或者 form 对象代替反射特定的 actionform 子类。可以定制的绑定和数据校验:作为应用级的输入机制的错误 校验, 固定日期和数字绑定, 定制绑定和验证:类型不匹配,应用程序级验证错误, 使违规值,本地化的日期和号码绑定等代替 String-only 表单对象手工解析和转 换为业务对象。例如,通过手动检查和转换业务对象来替换单个的 spring。可 定制的操作,可定制的视图方案:通过名字/值 映射灵活的模型传送,用一个简 单的方法从简单到复杂操作映射和视图方案策略。 本地定制和主题方案:Spring 没有 taglib,完全支持于 JSPs,JSTL,不需 要额外的连接就可以支持 Veloctiy,等等。简单但是强大的 tag library 避免 混乱,最大限度的灵活拓展了标记代码。

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[19929],资料为PDF文档或Word文档,PDF文档可免费转换为Word

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。