Package net.mingsoft.basic.exception
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
FieldsFields inherited from class org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLoggerFields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.servlet.ModelAndViewhandleAuthenticationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.AuthenticationException e) 登录异常org.springframework.web.servlet.ModelAndViewhandleAuthorizationException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.AuthorizationException e) shiro权限错误org.springframework.web.servlet.ModelAndViewhandleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, net.mingsoft.base.exception.BusinessException e) 全局异常org.springframework.web.servlet.ModelAndViewhandleBusinessException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, BusinessException e) Deprecated.org.springframework.web.servlet.ModelAndViewhandleCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.CredentialsException e) shiro权限错误org.springframework.web.servlet.ModelAndViewhandleException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e) 全局异常org.springframework.web.servlet.ModelAndViewhandleExpiredSessionException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.session.ExpiredSessionException e) session失效异常org.springframework.web.servlet.ModelAndViewhandleHttpRequestMethodNotSupportedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.HttpRequestMethodNotSupportedException e) 请求方法类型错误org.springframework.web.servlet.ModelAndViewhandleIncorrectCredentialsException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.IncorrectCredentialsException e) shiro权限账号或密码错误org.springframework.web.servlet.ModelAndViewhandleLockedAccountException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authc.LockedAccountException e) shiro权限未授权异常org.springframework.web.servlet.ModelAndViewhandleMissingServletRequestParameterException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.bind.MissingServletRequestParameterException e) 请求参数异常org.springframework.web.servlet.ModelAndViewhandleNoHandlerFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.NoHandlerFoundException e) 全局异常 未找到类404org.springframework.web.servlet.ModelAndViewhandleNoResourceFoundException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.web.servlet.resource.NoResourceFoundException e) 全局异常 未找到资源404org.springframework.web.servlet.ModelAndViewhandleSqlException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception e) sql异常,不返回具体sql,防止暴露表结构org.springframework.web.servlet.ModelAndViewhandleSQLException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, SQLException e) SQL异常拦截,避免敏感SQL信息暴露org.springframework.web.servlet.ModelAndViewhandleUnauthorizedException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.apache.shiro.authz.UnauthorizedException e) shiro权限未授权异常org.springframework.web.servlet.ModelAndViewhandleValidExceptionHandler(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.validation.BindException e) 统一处理请求参数校验(实体对象传参)org.springframework.web.servlet.ModelAndViewuploadException(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, sendServerErrorMethods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
addMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
-
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:
-