Class GlobalExceptionResolver

java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
net.mingsoft.basic.exception.GlobalExceptionResolver
All Implemented Interfaces:
org.springframework.core.Ordered, org.springframework.web.servlet.HandlerExceptionResolver

@ControllerAdvice public class GlobalExceptionResolver extends org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
全局异常处理类
Author:
铭软开发团队-Administrator
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.slf4j.Logger
     

    Fields inherited from class org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver

    PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger

    Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver

    logger

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.web.servlet.ModelAndView
    handleAuthenticationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.AuthenticationException e)
    登录异常
    org.springframework.web.servlet.ModelAndView
    handleAuthorizationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.AuthorizationException e)
    shiro权限错误
    org.springframework.web.servlet.ModelAndView
    handleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, net.mingsoft.base.exception.BusinessException e)
    全局异常
    org.springframework.web.servlet.ModelAndView
    handleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, BusinessException e)
    Deprecated.
    org.springframework.web.servlet.ModelAndView
    handleCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.CredentialsException e)
    shiro权限错误
    org.springframework.web.servlet.ModelAndView
    handleException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e)
    全局异常
    org.springframework.web.servlet.ModelAndView
    handleExpiredSessionException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.session.ExpiredSessionException e)
    session失效异常
    org.springframework.web.servlet.ModelAndView
    handleHttpRequestMethodNotSupportedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.HttpRequestMethodNotSupportedException e)
    请求方法类型错误
    org.springframework.web.servlet.ModelAndView
    handleIncorrectCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.IncorrectCredentialsException e)
    shiro权限账号或密码错误
    org.springframework.web.servlet.ModelAndView
    handleLockedAccountException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.LockedAccountException e)
    shiro权限未授权异常
    org.springframework.web.servlet.ModelAndView
    handleMissingServletRequestParameterException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.bind.MissingServletRequestParameterException e)
    请求参数异常
    org.springframework.web.servlet.ModelAndView
    handleNoHandlerFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.NoHandlerFoundException e)
    全局异常 未找到类404
    org.springframework.web.servlet.ModelAndView
    handleNoResourceFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.resource.NoResourceFoundException e)
    全局异常 未找到资源404
    org.springframework.web.servlet.ModelAndView
    handleSqlException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e)
    sql异常,不返回具体sql,防止暴露表结构
    org.springframework.web.servlet.ModelAndView
    handleSQLException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SQLException e)
    SQL异常拦截,避免敏感SQL信息暴露
    org.springframework.web.servlet.ModelAndView
    handleUnauthorizedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.UnauthorizedException e)
    shiro权限未授权异常
    org.springframework.web.servlet.ModelAndView
    handleValidExceptionHandler(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.validation.BindException e)
    统一处理请求参数校验(实体对象传参)
    org.springframework.web.servlet.ModelAndView
    uploadException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.multipart.MaxUploadSizeExceededException e)
    上传文件异常捕获

    Methods inherited from class org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver

    doResolveException, handleAsyncRequestNotUsableException, handleAsyncRequestTimeoutException, handleConversionNotSupported, handleDisconnectedClientException, handleErrorResponse, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMethodArgumentNotValidException, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPartException, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, logException, sendServerError

    Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver

    addMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      protected final org.slf4j.Logger LOG
  • Constructor Details

    • GlobalExceptionResolver

      public GlobalExceptionResolver()
  • Method Details

    • handleBusinessException

      @ExceptionHandler(BusinessException.class) @Deprecated public org.springframework.web.servlet.ModelAndView handleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, BusinessException e)
      Deprecated.
      全局异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleBusinessException

      @ExceptionHandler(net.mingsoft.base.exception.BusinessException.class) public org.springframework.web.servlet.ModelAndView handleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, net.mingsoft.base.exception.BusinessException e)
      全局异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleException

      @ExceptionHandler(java.lang.Exception.class) public org.springframework.web.servlet.ModelAndView handleException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e)
      全局异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleSqlException

      @ExceptionHandler(org.springframework.jdbc.BadSqlGrammarException.class) public org.springframework.web.servlet.ModelAndView handleSqlException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e)
      sql异常,不返回具体sql,防止暴露表结构
      Parameters:
      request -
      response -
      e -
      Returns:
    • uploadException

      @ExceptionHandler(org.springframework.web.multipart.MaxUploadSizeExceededException.class) public org.springframework.web.servlet.ModelAndView uploadException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.multipart.MaxUploadSizeExceededException e) throws IOException
      上传文件异常捕获
      Parameters:
      request -
      response -
      e -
      Returns:
      Throws:
      IOException
    • handleNoHandlerFoundException

      @ExceptionHandler(org.springframework.web.servlet.NoHandlerFoundException.class) public org.springframework.web.servlet.ModelAndView handleNoHandlerFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.NoHandlerFoundException e)
      全局异常 未找到类404
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleNoResourceFoundException

      @ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class) public org.springframework.web.servlet.ModelAndView handleNoResourceFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.resource.NoResourceFoundException e)
      全局异常 未找到资源404
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleMissingServletRequestParameterException

      @ExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException.class) public org.springframework.web.servlet.ModelAndView handleMissingServletRequestParameterException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.bind.MissingServletRequestParameterException e)
      请求参数异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleHttpRequestMethodNotSupportedException

      @ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) public org.springframework.web.servlet.ModelAndView handleHttpRequestMethodNotSupportedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.HttpRequestMethodNotSupportedException e)
      请求方法类型错误
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleValidExceptionHandler

      @ExceptionHandler(org.springframework.validation.BindException.class) public org.springframework.web.servlet.ModelAndView handleValidExceptionHandler(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.validation.BindException e)
      统一处理请求参数校验(实体对象传参)
      Parameters:
      e - BindException
      Returns:
      ResultResponse
    • handleUnauthorizedException

      @ExceptionHandler(org.apache.shiro.authz.UnauthorizedException.class) public org.springframework.web.servlet.ModelAndView handleUnauthorizedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.UnauthorizedException e)
      shiro权限未授权异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleLockedAccountException

      @ExceptionHandler(org.apache.shiro.authc.LockedAccountException.class) public org.springframework.web.servlet.ModelAndView handleLockedAccountException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.LockedAccountException e)
      shiro权限未授权异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleIncorrectCredentialsException

      @ExceptionHandler(org.apache.shiro.authc.IncorrectCredentialsException.class) public org.springframework.web.servlet.ModelAndView handleIncorrectCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.IncorrectCredentialsException e)
      shiro权限账号或密码错误
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleAuthenticationException

      @ExceptionHandler(org.apache.shiro.authc.AuthenticationException.class) public org.springframework.web.servlet.ModelAndView handleAuthenticationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.AuthenticationException e)
      登录异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleAuthorizationException

      @ExceptionHandler(org.apache.shiro.authz.AuthorizationException.class) public org.springframework.web.servlet.ModelAndView handleAuthorizationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.AuthorizationException e)
      shiro权限错误
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleCredentialsException

      @ExceptionHandler(org.apache.shiro.authc.CredentialsException.class) public org.springframework.web.servlet.ModelAndView handleCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.CredentialsException e)
      shiro权限错误
      Parameters:
      e -
      Returns:
    • handleExpiredSessionException

      @ExceptionHandler(org.apache.shiro.session.ExpiredSessionException.class) public org.springframework.web.servlet.ModelAndView handleExpiredSessionException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.session.ExpiredSessionException e)
      session失效异常
      Parameters:
      request -
      response -
      e -
      Returns:
    • handleSQLException

      @ExceptionHandler(java.sql.SQLException.class) public org.springframework.web.servlet.ModelAndView handleSQLException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SQLException e)
      SQL异常拦截,避免敏感SQL信息暴露
      Parameters:
      request -
      response -
      e -
      Returns: