0

使用 Spring WebFlow Flow 处理全局异常。

我在一个 Spring webflow 项目中工作,我想知道是否有人知道如何在流中添加某种类型的全局异常处理,所以如果我的任何 java 调用抛出一个示例,它将捕获并引入相同的错误系统整个系统?

我的旧流程解决了一个问题:

<var name="member" class="xxxx" />
<decision-state id="checkIsInPending">
   <if test="flowControllerActions.isInPending(member)" then="endStateMemberPending" else="name" />
</decision-state>

一旦我将全局添加到其中,我就开始出现错误。

<var name="member" class="xxxxx" />

    <global-transitions>
        <transition on-exception="java.lang.Exception"
                    to="SystemException" />
    </global-transitions>


    <decision-state id="checkIsInPending">
        <if test="flowControllerActions.isInPending(member)" then="endStateMemberPending" else="name" />
    </decision-state>

这是我的错误:

org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 40; cvc-complex-type.2.4.a: Invalid content was found starting with element 'decision-state'. One of '{"http://www.springframework.org/schema/webflow":on-end, "http://www.springframework.org/schema/webflow":output, "http://www.springframework.org/schema/webflow":exception-handler, "http://www.springframework.org/schema/webflow":bean-import}' is expected.
4

2 回答 2

1

您可以使用全局转换来捕获异常:

<global-transitions>
    <transition on-exception="example.MyBusinessException" to="state3"/>
</global-transitions>

有关更多详细信息,请参阅:文档

于 2013-01-30T13:30:33.180 回答
1

尝试重新排列 XML 标记。您收到此异常是因为您的流 XML 不符合 XSD。Myabe 只是把 global-transition 放在最后

于 2013-01-30T13:49:07.403 回答