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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15453938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 19:39:46  来源:igfitidea点击:

How to implement Switch/if else if statement in spring webflow?

javaspringspring-mvcspring-webflow

提问by user1938073

Have implemented switch statement as below.

已实现如下 switch 语句。

Could you please verify and correct it if there is any wrong?

如果有错误,请您核实并纠正它吗?

<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>

And please let me know is this way of implementation supports in spring webflow 2.0

请让我知道这种实现方式在 spring webflow 2.0 中是否支持

Thanks in advance.

提前致谢。

回答by ?ukasz Rzeszotarski

Quoting the documentation

引用文档

for decision states

对于决策状态

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

as an alternative for

作为替代

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

Analogically for view states

类似地用于视图状态

<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>

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

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