Spring web flow 配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/index">index1</prop>
<prop key="/shopping">flowController</prop>
</props>
</property>
</bean>
<bean id="index1" class="org.springframework.web.servlet.mvc.ParameterizableViewController" >
<property name="viewName" value="index"></property>
</bean>
<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<!--FlowController可以理解为时flow的入口,也就是spring mvc与spring web flow的结合点,将请求交给词控制器处理就表示进入到flow中去,具体进入到哪一个flow就是靠flowExecutor来判断,判断的方式是根据请求的URL,那么在本例中将会进入到id为shopping的flow-->
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
<!-- 所有 flow的定义文件它的位置在这里进行配置, flow-builder-services 用于配置 flow 的特性 -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/flows/shopping.xml" id="shopping" />
<webflow:flow-location path="/WEB-INF/flows/addToCart.xml" id="addToCart" />
</webflow:flow-registry>
<!--Web Flow 中的视图通过 MVC 框架的视图技术来呈现 -->
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" />
<!-- 指明 MVC 框架的 view resolver ,用于通过 view 名查找资源 -->
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="viewResolver" />
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<!-- view-state中的view对应jsp文件夹中的jsp页面,on是触发事件,to对应state id -->
<!-- <var name="mycart" class="bean.Cart"/> 表示定义一个名为mycart的变量,其值为bean.Cart类对象
这种方式可以使用spring注解代替:@Component("mycart")
-->
<on-start> <!-- 表示在进入此flow之前执行 -->
<set name="conversationScope.cart" value="mycart"></set> <!-- 表示将mycart放入到conversation范围内的cart中 -->
</on-start>
<view-state id="viewCart" view="/jsp/viewCart" > <!-- 我们可以看到这是此flow的第一个state,那么当进入到这个flow时 -->
<on-render> <!--在这个视图渲染之前,执行里面的业务逻辑--> <!--首先执行这个state,即进入到viewCart页面 -->
<evaluate expression="productService.getProducts()" result="viewScope.products"/>
<!-- expression表达式表示业务逻辑,将该方法的返回值放入到view范围内的products中 -->
</on-render>
<transition on="submit" to="viewOrder"><!--当在此状态下,如果触发submit,则会转向viewOrder状态 -->
</transition>
<transition on="addToCart" to="addProductToCart"/>
</view-state>
<view-state id="viewOrder" view="/jsp/viewOrder">
<transition on="confirm" to="orderConfirmed">
</transition>
</view-state>
<view-state id="orderConfirmed" view="/jsp/viewConfirmed">
<transition on="returnToIndex" to="returnToIndex">
</transition>
</view-state>
<end-state id="returnToIndex" view="index">
</end-state><!-- 次flow的结束状态 ,不能再转向其他状态-->
<subflow-state id="addProductToCart" subflow="addToCart"> <!-- 子流,subflow表示子flow的id -->
<transition on="productAdded" to="viewCart" />
</subflow-state>
</flow>
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<on-start>
<set name="requestScope.productId" value="requestParameters.productId"/>
</on-start>
<action-state id="addToCart">
<evaluate expression="cart.addItem(productService.getProduct(productId))"/>
<transition to="productAdded"/>
</action-state> <!-- 此state就是用来处理业务逻辑的 -->
<end-state id="productAdded"/>
</flow>
Spring web flow 配置文件相关推荐
- 笔记41 Spring Web Flow——Demo
订购披萨的应用整体比较比较复杂,现拿出其中一个简化版的流程:即用户访问首页,然后输入电话号(假定未注册)后跳转到注册页面,注册完成后跳转到配送区域检查页面,最后再跳转回首页.通过这个简单的Demo用来 ...
- Spring Web Flow 简单实现-自定义配置文件位置
前言 在文章 Spring Web Flow 简单实现 中,我们把Web Flow 的的配置文件和 jsp 页面文件统一放置在了 WEB-INF 目录下,事实上,那种情况下我们不得不这样做. 这片文章 ...
- 用Spring Web Flow和Terracotta搭建Web应用
什么是Spring Web Flow? Spring Web Flow是Spring Framework中的web应用组件,它提供了一种编写有状态和基于会话的web应用的简便手段.Spring Web ...
- Spring Web Flow实例教程
目录: 参考文献 购物车用例 什么情况下可以使用 Spring Web Flow? 配置 Spring Web MVC 配置 Spring Web Flow 2.0 的基础 在购物车示例应用中配置 S ...
- Spring Web Flow 2.0 入门详解
目录: 参考文献 购物车用例 什么情况下可以使用 Spring Web Flow? 配置 Spring Web MVC 配置 Spring Web Flow 2.0 的基础 在购物车示例应用中配置 S ...
- Spring Web Flow 入门demo(三)嵌套流程与业务结合 附源码
转载地址 ; http://blog.csdn.net/hejingyuan6/article/details/46723021 上篇博客我们说spring web Flow与业务结合的方式主要有三种 ...
- Spring Web Flow 入门demo(一)简单页面跳转 附源码
转载地址 http://blog.csdn.net/hejingyuan6/article/details/46508821 spring Web Flow (SWF)是Spring Framewor ...
- 笔记36 Spring Web Flow——配置
Spring Web Flow是一个Web框架,它适用于元素按规定流程运行的程序.Spring Web Flow是Spring MVC的扩展,它支持开发基于流程的应用程 序.它将流程的定义与实现流程行 ...
- 《Spring Web Flow 实践》
<Spring Web Flow 实践> 在<Spring In Action>这本书上的第八章介绍了Spring Web Flow的相关知识. 在<Spring In ...
最新文章
- python标准库学习4
- viewpager默认界面_使用默认方法的界面演变–第一部分:方法
- 无中生有!没有视觉信号的视觉语音增强
- Excel文档VBA代码自动删除
- Lync2010标准版部署
- 利用Linq对集合元素合并、去重复处理
- hdu1023-----卡特兰数
- pycharm汉化(搜索不到插件的参考第二中方法)
- 戴尔服务器r720u盘装系统,DELL R720服务器U盘安装操作系统指南
- 网络工程师HCNA认证学习笔记Day1
- vs2017 安装MFC
- 四种隔离级别及应用场景
- Unity 引擎 Managed Stripping Level 遇到的坑
- 【ggplot】复杂柱状图:自定义颜色、标签、位置、坐标轴和主题
- 游戏开发主要学哪些课程?
- 使用app inventor快速开发安卓app(第二课,音乐播放器)
- 蚂蚁花呗账单分期和交易分期的费用如何计算?
- Day17:web前端开发面试题
- MVVM理解 ——(2)数据劫持
- java打包把依赖也打进去_maven打包时把依赖的jar包打进去