我正在尝试创建一个过滤器来处理异常(请参阅在 JSF 中处理未捕获的异常)
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
log.info("check filter is running");
chain.doFilter(request, response);
} catch (Exception e) {
log.error("Uncaught exception",e);
request.setAttribute("exception", e);
request.getRequestDispatcher("/error.xhtml").forward(request, response);
}
}
我执行以下方法:
<p:commandButton value="Dispatch Order" update="@form"
action="#{orderBean.dispatchOrder()}">
</p:commandButton>
但是,不处理任何异常。
我在日志中看到错误:
May 21, 2013 6:04:32 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{orderBean.dispatchOrder()}: MyException.....
我究竟做错了什么?