Spring Webflow - 决策状态与动作状态 [英] Spring Webflow - decision-state vs action-state
问题描述
我正在使用Spring WebFlow 2,我想知道决策状态与动作状态的区别。
I am using Spring WebFlow 2 and I want to know the diff of decision-state vs action-state.
我正在阅读并且不理解差异决策状态与行动状态。我理解视图状态会显示一个输入的jsp,但是决策状态与动作状态的差异是什么?
I am reading up and dont understand the diff of decision-state vs action-state. I understand that view-state will display a jsp for input but whats the diff of decision-state vs action-state?
为什么我应该使用决策状态而不是动作-州?
为什么我应该在决策状态下使用动作状态?
why should I use decision-state over a action-state? why should I use a action-state over a decision-state?
有人可以点亮这个
推荐答案
通常,决策状态
专门用于布尔条件。它更清晰简洁。
Generally, decision-state
is used exclusively for a boolean conditional. It's more clear and concise as to what it occurs.
例如,
<decision-state id="myDecisionState">
<if test="myBooleanFunction()" then="resultIsTrueState" else="resultIsFalseState" />
</decision-state>
可以使用动作状态
像这样:
<action-state id="myActionState">
<evaluate expression="myBooleanFunction()" />
<transition on="yes" to="resultIsTrueState" />
<transition on="no" to="resultIsFalseState" />
</action-state>
然而,区别在于 action-state
不只是操作布尔值 - 它可以触发转换字符串(字符串值)
,布尔值(是/否)
,枚举(枚举名称)
,其他任何结果都被视为成功
。
However, the difference is that action-state
does not just operate on booleans - it can trigger transitions on String (string value)
, Boolean (yes/no)
, Enum (enum name)
with any other result considered a success
.
因此,与决策状态
形成对比,实际必须决定,操作-state
可以简单地用于执行某些代码。
So, by contrast to a decision-state
which actually has to decide something, an action-state
can simply be used to execute some code.
<action-state id="myActionState">
<evaluate expression="myFunction()" />
<transition on="success" to="myNextState" />
</action-state>
我希望能够解决问题。
这篇关于Spring Webflow - 决策状态与动作状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!