Spring Web Flow的目标是成为管理web应用网页流的最好的解决方案。
SWF集成了现有的框架像Spring MVC 和JSP,适用于Servlet和Porlet环境。如果你有一个业务流程,需要一个对话式的模型而不是单纯的请求模型,那么SWF可能就是解决方案。
Spring的web模块包含了很多独立的web支持特性:
- 清晰的角色划分。每一个角色--controller,validator,command object,form object,model object, DispatcherServlet,handler mapping,view resolver,等等都可以被专门的对象实现。
- 强大的、直接的框架和应用classes的配置。配置能力包括简单的上下文的引用像从web controller到业务对象和validator。
- 适配性,非入侵性,以及弹性。定义任何一个controller方法,在特定场景下你可能只需要使用一个带参数的注解(像@RequestParam,@RequestHeader,@PathValiable等)
- 可复用的业务代码,不需要重复复制。使用已有的业务对象来充当命令或表单对象而不是复制他们来继承一个特定框架的基类
- 可定制的绑定和验证。类型错误像应用级别的验证错误使用提供的值,本地化日期,和数字绑定,不再是手动将表单对象转化绑定到业务对象上
- 可定制的handler mapping和view resolution.Handler mapping和view resolution策略包含从简单的基于URL的配置到复杂的专用的解决策略。Spring比其他的要求使用特性视图技术的web MVC框架更灵活。
- 灵活的模型传输。模型通过name/value的Map传输,可以简单的与任何一种视图技术集成
- 可定制的本地化,时间区域,和主题解决方案,支持JSP(使用或不适用Spring的tag library),支持JSTL,支持Velocity不需要其他的搭建等等。
- 简单但强大的JSP tag library ,就是Spring tag library,提供了数据绑定和主题等特性。
英文原文:
- Clear separation of roles. Each role — controller, validator, command object, form object, model object,
DispatcherServlet
, handler mapping, view resolver, and so on — can be fulfilled by a specialized object. - Powerful and straightforward configuration of both framework and application classes as JavaBeans. This configuration capability includes easy referencing across contexts, such as from web controllers to business objects and validators.
- Adaptability, non-intrusiveness, and flexibility. Define any controller method signature you need, possibly using one of the parameter annotations (such as @RequestParam, @RequestHeader, @PathVariable, and more) for a given scenario.
- Reusable business code, no need for duplication. Use existing business objects as command or form objects instead of mirroring them to extend a particular framework base class.
17.1.1 Features of Spring Web MVC
Spring’s web module includes many unique web support features:
- Clear separation of roles. Each role — controller, validator, command object, form object, model object,
DispatcherServlet
, handler mapping, view resolver, and so on — can be fulfilled by a specialized object. - Powerful and straightforward configuration of both framework and application classes as JavaBeans. This configuration capability includes easy referencing across contexts, such as from web controllers to business objects and validators.
- Adaptability, non-intrusiveness, and flexibility. Define any controller method signature you need, possibly using one of the parameter annotations (such as @RequestParam, @RequestHeader, @PathVariable, and more) for a given scenario.
- Reusable business code, no need for duplication. Use existing business objects as command or form objects instead of mirroring them to extend a particular framework base class.
- Customizable binding and validation. Type mismatches as application-level validation errors that keep the offending value, localized date and number binding, and so on instead of String-only form objects with manual parsing and conversion to business objects.
- Customizable handler mapping and view resolution. Handler mapping and view resolution strategies range from simple URL-based configuration, to sophisticated, purpose-built resolution strategies. Spring is more flexible than web MVC frameworks that mandate a particular technique.
- Flexible model transfer. Model transfer with a name/value
Map
supports easy integration with any view technology. - Customizable locale, time zone and theme resolution, support for JSPs with or without Spring tag library, support for JSTL, support for Velocity without the need for extra bridges, and so on.
- A simple yet powerful JSP tag library known as the Spring tag library that provides support for features such as data binding and themes. The custom tags allow for maximum flexibility in terms of markup code. For information on the tag library descriptor, see the appendix entitled Chapter 36, spring.tld
- A JSP form tag library, introduced in Spring 2.0, that makes writing forms in JSP pages much easier. For information on the tag library descriptor, see the appendix entitledChapter 37, spring-form.tld
- Beans whose lifecycle is scoped to the current HTTP request or HTTP
Session
. This is not a specific feature of Spring MVC itself, but rather of theWebApplicationContext
container(s) that Spring MVC uses. These bean scopes are described in Section 5.5.4, “Request, session, and global session scopes”
- Clear separation of roles. Each role — controller, validator, command object, form object, model object,
- Clear separation of roles. Each role — controller, validator, command object, form object, model object,
DispatcherServlet
, handler mapping, view resolver, and so on — can be fulfilled by a specialized object. - Powerful and straightforward configuration of both framework and application classes as JavaBeans. This configuration capability includes easy referencing across contexts, such as from web controllers to business objects and validators.
- Adaptability, non-intrusiveness, and flexibility. Define any controller method signature you need, possibly using one of the parameter annotations (such as @RequestParam, @RequestHeader, @PathVariable, and more) for a given scenario.
- Reusable business code, no need for duplication. Use existing business objects as command or form objects instead of mirroring them to extend a particular framework base class.