webflow1.06升级到2.4.4

因项目原因,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">
			<bean
				class="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)

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

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值