【问题标题】:Global Exception handing with Spring WebFlow Flow使用 Spring WebFlow Flow 处理全局异常
【发布时间】:2013-01-31 16:12:23
【问题描述】:

使用 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.

【问题讨论】:

    标签: java spring spring-mvc spring-webflow


    【解决方案1】:

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

    【讨论】:

    • 我将 global-transition 移到了文件的末尾,现在看起来它正在工作
    • flow.xml 文件确实有一个预期的序列,如果您使用的是 XSD 感知编辑器,XSD 会强制执行该序列。尝试将全局转换放在文件的最后。
    【解决方案2】:

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

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

    更多详情请见:the documentation

    【讨论】:

    • 感谢 Piyush,但我为我的问题添加了更多细节。您的代码不起作用
    猜你喜欢
    • 2012-10-16
    • 2016-11-18
    • 2021-08-19
    • 2013-04-02
    • 1970-01-01
    • 2018-07-19
    • 2016-11-03
    • 2018-11-19
    • 2014-07-17
    相关资源
    最近更新 更多