Spring WebFlow可以了解之前的状态吗

Spring WebFlow can I understand the previous state

我有一个简单的 Spring WebFlow,它有几个状态。

有没有可能到了某个状态就知道前一个是哪一个?

我需要这个,因为我想检测用户何时刷新页面,所以在这种情况下,我以前的状态将与我当前的状态相同。

你可以像这样设置一个变量:

<var name="comingFrom" class="java.lang.String"/>

<on-start>
    <set name="comingFrom" value="''"/>
<on-start>

<state id="state1">
    <transition on="transition1" to="current">
        <set name="comingFrom" value="'state1'"/>
    </transition>
</state>

<state id="current">
    /* do what you want in your state with "comingFrom" */
    <transition on="transistion2">
        <set name="comingFrom" value="'current'"/>
    </transition>
</state>

但这需要您在每个进入 "current" 状态的转换中设置此变量。

[编辑] 决策状态示例:

<decision-state id="decisionState">
    <if test="comginFrom != 'current'" then="state1" else="state2"/>
</decision-state>