| | |
| | | package com.ruoyi.framework.web.exception;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import jakarta.servlet.http.HttpServletRequest;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.security.access.AccessDeniedException;
|
| | |
| | | import org.springframework.web.HttpRequestMethodNotSupportedException;
|
| | | import org.springframework.web.bind.MethodArgumentNotValidException;
|
| | | import org.springframework.web.bind.MissingPathVariableException;
|
| | | import org.springframework.web.bind.MissingServletRequestParameterException;
|
| | | import org.springframework.web.bind.annotation.ExceptionHandler;
|
| | | import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| | | import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 请求参数缺失
|
| | | */
|
| | | @ExceptionHandler(MissingServletRequestParameterException.class)
|
| | | public AjaxResult handleMissingServletRequestParameterException(MissingServletRequestParameterException e, HttpServletRequest request)
|
| | | {
|
| | | String requestURI = request.getRequestURI();
|
| | | log.error("请求地址'{}',缺少必需的请求参数'{}'", requestURI, e.getParameterName());
|
| | | return AjaxResult.error(String.format("缺少必需的请求参数[%s]", e.getParameterName()));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 请求参数类型不匹配
|
| | | */
|
| | | @ExceptionHandler(MethodArgumentTypeMismatchException.class)
|