gpt4 book ai didi

java - Spring WebFlow 中的动态转换

转载 作者:行者123 更新时间:2023-11-29 05:41:53 25 4
gpt4 key购买 nike

有人知道是否可以在 Spring Web Flow 定义中定义动态转换吗?

示例 1 - 使用属性文件:

<action-state id="createSubscription" >
<evaluate expression="myvar" />
<transition on="$[test.result.valid]" to="subscribeUser-successResponse" />
<transition to="subscribeUser-exceptionResponse" />
</action-state>

示例 2 - 使用变量本身的值:

<action-state id="createSubscription" >
<evaluate expression="myvar" />
<transition to="$[myvar]" />
</action-state>

这不是强制性的,但可以帮助设计更通用的流程。

在此先感谢大家。

最佳答案

你绝对可以做“到”的过渡。假设流 xml 有一些 Action 和 View 状态:

    <action-state id="createSubscription">
<evaluate expression="myAction.prepareNextState(flowScope.formBean)"/>
<transition to="${flowScope.formBean.displayNextState}">
</action-state>

<view-state id="someView" view="someView" model="formBean">
...
</view-state>

带有 prepareNextState 方法的 myAction 类如下:

    public class MyAction implements Serializable{
....
public void prepareNextState(FormBean formBean){
//displayNextState is a String field in FormBean
formBean.setDisplayNextState("someView");
}
....
}

这样我们就可以为“to”的过渡定义通用的过渡。

关于java - Spring WebFlow 中的动态转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17180465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com