目前,我正在利用“海关服务包”处理一项申请,以追捕所有例外:
<filter-mapping>
<filter-name>ExceptionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
以及
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
chain.doFilter(request, response);
} catch (Throwable t) {
if (request instanceof HttpServletRequest) {
log.error(((HttpServletRequest) request).getRequestURL());
}
log.error("Exception:", t);
String path = "/error.do";
request.getRequestDispatcher(path).forward(request, response);
}
}
After investigating for some time I have found SimpleMappingExceptionResolver as an easy way to h以及le exception 以及 view mappings 以及 as I see I can not use both but I can not see any reason to prefer one method above the other one.
I underst以及 that it is easier to map diferent errors to different views using the resolver but we only use one error view, so I am more concerned about perfomance of both solutions, if one of the will be able to h以及le a broader range of exceptions 以及 such things.
Thanks in advance to all of you Spring experts