code: @Override
      public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
                                           Object o, Exception e) {
          ModelAndView model = new ModelAndView(new MappingJacksonJsonView());
          try {
              if (e instanceof TypeMismatchException) {
                  LOG.warn("TypeMismatchException occurred. " + e.getMessage());
                  return buildBizErrors((TypeMismatchException) e, model);
              } else if (e instanceof BindException) {
                  LOG.warn("BindException occurred. " + e.getMessage());
                  return buildBizErrors((BindException) e, model);
              } else if (e instanceof HttpRequestMethodNotSupportedException) {
                  LOG.warn("HttpRequestMethodNotSupportedException occurred. " + e.getMessage());
                  return buildError(model, GlobalResponseStatusMsg.REQUEST_HTTP_METHOD_ERROR);
              } else if (e instanceof MissingServletRequestParameterException) {
                  LOG.warn("MissingServletRequestParameterException occurred. " + e.getMessage());
                  return buildError(model, GlobalResponseStatusMsg.PARAM_MISS_ERROR);
              } else {
                  LOG.error("System error occurred. " + e.getMessage(), e);
                  return buildError(model, GlobalResponseStatusMsg.SYSTEM_ERROR);
              }
          } catch (Exception ex) {
              // Omit all detailed error message including stack trace to external user
              LOG.error("Unexpected error occurred! This should never happen! " + ex.getMessage(), ex);
              model.addObject("status", SYS_ERROR_CODE);
              model.addObject("msg", SYS_ERROR_MSG);
              return model;
          }
      }
docs: 全局处理错误
  
  @param request  current HTTP request
  @param response current HTTP response
  @param handler  the executed handler, or <code>null</code> if none chosen at the time of the exception (for
  example,
  if multipart resolution failed)
  @param ex       the exception that got thrown during handler execution
  
  @return a corresponding ModelAndView to forward to, or <code>null</code> for default processing
  
  @see org.springframework.web.servlet.HandlerExceptionResolver#resolveException(javax.servlet.http
  .HttpServletRequest,
  javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.Exception)