对于异常我们可以通过注册一个实现HandlerExceptionResolver接口的Bean来解决

    1. @Component
    2. public class CustomerHandlerException implements HandlerExceptionResolver {
    3. @Override
    4. public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    5. System.err.println(handler.getClass()+" "+request.getRequestURI()+" "+ex.getMessage());
    6. return null;
    7. }
    8. }