问题
Hello Friends Iam trying to handle
org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException
this exception but iam failed to do so. In this way i handle SnapshotNotFoundException.
<transition on-exception="org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException"
to="exceptionHandler" />
回答1:
That declarative Exception handling does not seem to work for internal Web Flow exceptions. For this particular case, we had to implement a custom FlowHandler.handleException().
Something like:
public class CustomFlowHandler extends AbstractFlowHandler
{
@Override
public String handleException(FlowException e, HttpServletRequest request,
HttpServletResponse response)
{
if (e instanceof FlowExecutionRestorationFailureException)
{
if (e.getCause() instanceof SnapshotNotFoundException)
{
// TODO return the desired location string. See javadoc for options
return "serverRelative:/missingSnapshot.html";
}
}
return super.handleException(e, request, response);
}
}
And in Spring configuration file:
<!-- custom flow handler -->
<bean name="your-flow-name" class="yourpackage.CustomFlowHandler"/>
来源:https://stackoverflow.com/questions/24116852/handle-exception-in-spring-web-flow