天天看點

webflow1.06更新到2.4.41.替換新的jar包2.配置檔案

因項目原因,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)

有什麼不足之處,及時指出