webflow1.06升级到2.4.4

来源:互联网 发布:sql删除某列数据 编辑:程序博客网 时间:2024/05/22 16:39

因项目原因,spring从2.4直接升级的4.2.2,由于webflow和spring之间存在着关联,webflow也面临着需要升级。网络上关于webflow的资料少,能看懂的资料更少,升级的资料更是只找到一篇。在同事们的大力支持下,完成了升级,先感谢各位同事的鼎力相助。

1.替换新的jar包

2.配置文件

2.1webflow的XML头文件的变动

http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd 改为 http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd
把1.0该为2.0,而不是改为2.4,时间原因,没有测试改为2.4会有什么结果,后续会补上。

2.2 与spring配置文件结合

1.0 相关的配置
<bean id="xxxxxxxxxxxxxxxxxxxxxxB"class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="mappings"><props><prop key="/login">xxxController</prop></props></property><property name="interceptors"><list><ref bean="localeChangeInterceptor" /></list></property></bean><bean id="xxxController"class="org.springframework.webflow.executor.mvc.FlowController"p:flowExecutor-ref="flowExecutor" p:defaultFlowId="login-webflow"><property name="argumentHandler"><beanclass="org.springframework.webflow.executor.support.RequestParameterFlowExecutorArgumentHandler"p:flowExecutionKeyArgumentName="lt" p:defaultFlowId="login-webflow" /></property></bean><flow:executor id="flowExecutor" registry-ref="flowRegistry"><flow:execution-attributes><flow:alwaysRedirectOnPause value="false" /></flow:execution-attributes></flow:executor><flow:registry id="flowRegistry"><flow:location path="/WEB-INF/login-webflow.xml" /></flow:registry>
2.4相关配置
<bean id="viewResolver"class="org.springframework.web.servlet.view.ResourceBundleViewResolver"p:order="0"><property name="basenames"><list><value>${xxx.viewResolver.basename}</value><value>xxxxx_views</value></list></property></bean>     <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /><!-- webflow配置 --> <bean name="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">        <property name="flowExecutor" ref="flowExecutor"/>    </bean>       <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">        <property name="mappings">            <props>                <prop key="/login.do">flowController</prop>            </props>        </property>    </bean>      <webflow:flow-executor id="flowExecutor" />        <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">        <webflow:flow-location path="/WEB-INF/login-webflow.xml" id="login" />    </webflow:flow-registry>          <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" />        <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">        <property name="viewResolvers" ref="viewResolver" />    </bean> 

2.3webflow的XML

在2.0的配置中,删除掉了<start-state idref="initialFlowSetup" />
<action-state>标签:把1.0的
<action-state id="initialFlowSetup"><action bean="initialFlowSetupAction" /><transition on="submit" to="submit" /></action-state>
改为了
<action-state id="initialFlowSetup"><evaluate expression="initialFlowSetupAction"/><transition on="submit"to="submit" /></action-state>
把action标签改为了evaluate表达式的方式。在网络上也看到有这种配置:initialFlowSetupAction.doExecute(flowRequestContext),其中flowRequestContext必须这么写,也不需要配置什么但是项目不知道何种原因,使用了这种配置,项目报错,找不到doExecute方法,只好放弃,直接使用initalflowsetupaction这种配置方法。
注意使用1.0配置需要自己去要配置initialFlowSetupAction的bean。
<view-state>标签:
把1.0的
<view-state id="viewLoginForm" view="casLoginView"><render-actions><action bean="authenticationViaFormAction"method="setupForm" /><action bean="authenticationViaFormAction"method="referenceData" /></render-actions><transition on="submit" to="bindAndValidate" /></view-state>
改为2.0的
<view-state id="viewLoginForm" view="casLoginView"><on-render><evaluate expression="authenticationViaFormAction.setupForm(flowRequestContext)"  /><evaluate expression="authenticationViaFormAction.referenceData(flowRequestContext)" /></on-render><transition on="submit" to="bindAndValidate" /></view-state>

其他标签均未改动。
需要主要的是flowRequestContext引用的是:org.springframework.webflow.execution.RequestContext 
Event 引用的是org.springframework.webflow.execution.Event
submit方法:public final Event submit(final RequestContext context)

有什么不足之处,及时指出

原创粉丝点击