中英文翻译

更新时间:2023-05-03 01:09:21 阅读: 评论:0

外文资料原文
Web MVC with the 漂亮妈妈张琳的故事 Spring Framework
Juergen Hoeller
1.      Introduction: Spring the Application Framework
When first confronted with the Spring Framework, one might be tempted to think: "Oh no, not yet another web framework". This article will outline why Spring isn't particularly a web framework but a generic lightweight application framework with dedicated web support, and show the architectural differences to Struts and WebWork
In contrast to Struts or WebWork, Spring is an application framework for all layers: It offers a bean configuration foundation, AOP support, a JDBC abstraction framework, abstract transaction support, etc. It is a very non-intrusive effort: Your application class do not need to depend on any Spring class if not necessary, and you can reu every part on its own if you like to. From its very design, the framework encourages clean paration of tiers,
most importantly web tier and business logic: e.g. the validation framework does not depend on web controllers. Major goals are reusability and testability: Unnecessary container or framework dependencies can be considered avoidable evils.
Of cour, Spring's own web support is nicely integrated with the framework's general patterns. Nevertheless, replacing the web solution with Struts, WebWork, or the like is easy. Both with Spring's web support or a different one, Spring allows for building a true dedicated middle tier in the web container, with the option to reu exactly the same business logic in test environments or standalone applications. And within J2EE, your busin中国第一位皇帝 ess logic will not unnecessarily depend on container rvices like JTA or EJB - allowing complex, wel立春吃什么食物养生 l-architected web applications to run in a "simple" container like Tomcat or Resin.
Note that Spring doesn't generally aim to compete with existing solutions. It rather fosters amless integration with standards like Servlet, JSP, JTA, JNDI, JDBC, and JDO, and well-suited tools like Hibernate, Velocity, Log4J, and Caucho's Hessian/Burlap. The frame
work is designed to grow with the needs of your applications, in terms of technology choice: For example, you will probably u JTA via Spring's JtaTransactionManager if you need distributed trans不屈不饶的意思 actions - but only then, as there are perfect replacements for single databas, like DataSourceTransactionManager or HibernateTransactionManager.
2.      Web MVC: The Design of Spring's Web Framework
Spring's web framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, and locale and theme resolution. The default handler is a very simple Controller interface, just offering a "ModelAndView handleRequest(request,respon)" method. This can already be ud for application controllers, but you will prefer t齐肩直发发型图片 he included implementation hierarchy, consisting of AbstractController, AbstractCommandController, MultiActionController, SimpleFormController, AbstractWizardFormController. Application controllers will typically be subclass of tho. Note that you can choo an appropriate ba class: If you don't have a form, you don't need a FormController. This is a major四姑娘山镇 difference to Struts.
You can take any object as command or form object: There's no need to implement an interface or derive from a ba class. Spring's data binding is highly flexible, e.g. it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. So you don't need to duplicate your business objects' properties as Strings in your form objects, just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it's often preferable to bind directly to your business objects. This is another major difference to Struts which is built around required ba class like Action and ActionForm - for every type of action.  Compared to WebWork, Spring has more differentiated object roles: It supports the notion of a Controller, an optional command or form object, and a model that gets pasd to the view. The model will normally include the command or form object but also arbitrary reference data. Instead, a WebWork Action combines all tho roles into one single object. WebWork does allow you to u existing business objects as part of your form, but just by making them bean properties of the respective Action class. Finally, the same Action instance that handles the request gets ud for evaluation and form population in the view. Thus, reference dat
a needs to be modelled as bean properties of the Action too. The are arguably too many roles in one object.
Regarding views: Spring's view resolution is extremely flexible. A Controller implementation can even write a view directly to the respon, returning null as ModelAndView. In the normal ca, a ModelAndView instance consists of a view name and a model Map, containing bean names and corresponding objects (like a command or form, reference data, etc). View name resolution is highly configurable, either via bean names, via a properties file, or via your own ViewResolver implementation. The abstract model Map allows for complete abstraction of the view technology, without any hassle: Be it JSP, Velocity, or anything el - every renderer can be integrated directly. The model Map simply gets transformed into an appropriate format, like JSP request attributes or a Velocity template model.
3.      Integration: Using a Different Web Framework with Spring

本文发布于:2023-05-03 01:09:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/853053.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:资料   外文   原文
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图