异常处理程序不捕获异常

Exception handler does not catch an exception

本文关键字:捕获异常 异常处理程序      更新时间:2023-09-26

我在webflow级别有一个异常处理程序

<exception-handler bean="webflowExceptionHandlerBean"/>

我还有两个不同的流程,流程A和流程B。流程B是流程A的子流程。

<flow>
  <on-start>
    <!-- SOME SET -->
  </on-start>
  <view-state id="viewStateA">
    <transition id="goToFlowB" to="flowB"/>
  </view-state>
  <subflow-state id="flowB" subflow="flowB">
  </subflow-state>
</flow>

流B

<flow>
  <on-start>
    <!-- SOME SET -->
  </on-start>
  <view-state id="flowB">
    <on-entry>
    <!-- HERE THE EXCEPTION IS THROWN -->
    </on-entry>
    <transition id="goToT1" to="t1"/>
  </view-state>
</flow>

因此,当流B的入口抛出异常时,该异常不会被webflowExceptionHandlerBean

捕获

webflowExceptionHandlerBean的配置实现FlowExecutionExceptionHandler

我试过使用,它工作了,但我想在每个流上只使用一个全局异常处理程序。

你知道发生了什么吗?我错过什么了吗?

有如下的抽象流定义

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
                            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" abstract="true">
<exception-handler bean="webflowExceptionHandlerBean"/>
</flow>

然后,继承抽象流到流A和流B中,如下所示

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
                            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" parent="abstract-flow">

您应该能够使用自定义异常处理程序来全局处理异常