3、Spring the Application Framework 

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 classes do not need to depend on any Spring classes if not necessary, and you can reuse every part on its own if you like to。 From its very design, the framework encourages clean separation 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 course, 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 reuse exactly the same business logic in test environments or standalone applications。 And within J2EE, your business logic will not unnecessarily depend on container services like JTA or EJB - allowing complex, well-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 seamless 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 framework is designed to grow with the needs of your applications, in terms of technology choice: For example, you will probably use JTA via Spring's JtaTransactionManager if you need distributed transactions - but only then, as there are perfect replacements for single databases, like DataSourceTransactionManager or HibernateTransactionManager。

4、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,response)" method。 This can already be used for application controllers, but you will prefer the included implementation hierarchy, consisting of AbstractController, AbstractCommandController, MultiActionController, SimpleFormController, AbstractWizardFormController。 Application controllers will typically be subclasses of those。 Note that you can choose an appropriate base 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 base 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 base classes 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 passed to the view。 The model will normally include the command or form object but also arbitrary reference data。 Instead, a WebWork Action combines all those roles into one single object。 WebWork does allow you to use 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 used for evaluation and form population in the view。 Thus, reference data needs to be modelled as bean properties of the Action too。 These 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 response, returning null as ModelAndView。 In the normal case, 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 else - 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。

上一篇:系统开发生命周期英文文献和中文翻译
下一篇:RP对不满足设计的RC结构的抗震加固英文文献和中文翻译

数控机床制造过程的碳排...

新的数控车床加工机制英文文献和中文翻译

抗震性能的无粘结后张法...

锈蚀钢筋的力学性能英文文献和中文翻译

未加筋的低屈服点钢板剪...

汽车内燃机连杆载荷和应...

审计的优化管理英文文献和中文翻译

张洁小说《无字》中的女性意识

麦秸秆还田和沼液灌溉对...

我国风险投资的发展现状问题及对策分析

网络语言“XX体”研究

老年2型糖尿病患者运动疗...

ASP.net+sqlserver企业设备管理系统设计与开发

互联网教育”变革路径研究进展【7972字】

LiMn1-xFexPO4正极材料合成及充放电性能研究

新課改下小學语文洧效阅...

安康汉江网讯