如何在spring webflow中实现Switch / if else if语句?

时间:2013-03-16 19:48:31

标签: java spring spring-mvc spring-webflow

已实现如下的switch语句。

如果有任何错误,请您验证并更正吗?

<set name="flowScope.Valid" value="true">
<decision-state id="isDNCheckNotRequired" test="Valid == true">
<transition on="true" to="even"/>
<transition on="false" to="odd"/>
</decision-state>

<action-state id="even">
<evaluate expression="Test.setEven(true)">
</action-state>

<action-state id="odd">
<evaluate expression="Test.set(false)">
</action-state>

请告诉我这是春天webflow 2.0中的实现方式支持

提前致谢。

1 个答案:

答案 0 :(得分:8)

引用文档

用于决策状态

<decision-state id="moreAnswersNeeded">
    <if test="interview.moreAnswersNeeded()" then="answerQuestions" else="finish" />
</decision-state>

作为

的替代方案
<action-state id="moreAnswersNeeded">
    <evaluate expression="interview.moreAnswersNeeded()" />
    <transition on="yes" to="answerQuestions" />
    <transition on="no" to="finish" />
</action-state>

类似于视图状态

<view-state id="uploadFile" model="uploadFileHandler">
    <var name="fileUploadHandler" class="org.springframework.webflow.samples.booking.FileUploadHandler" />
    <transition on="upload" to="finish" >
        <evaluate expression="fileUploadHandler.processFile()"/>
    </transition>
    <transition on="cancel" to="finish" bind="false"/>
</view-state>

请参阅:http://docs.spring.io/spring-webflow/docs/2.3.4.RELEASE/reference/html/actions.html#decision-state