Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-cloud
commit
0af36c40a0
|
@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||||
|
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
|
@ -86,6 +87,9 @@ public class GlobalExceptionHandler {
|
||||||
if (ex instanceof NoHandlerFoundException) {
|
if (ex instanceof NoHandlerFoundException) {
|
||||||
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
||||||
}
|
}
|
||||||
|
if (ex instanceof NoResourceFoundException) {
|
||||||
|
return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
|
||||||
|
}
|
||||||
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||||
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +179,15 @@ public class GlobalExceptionHandler {
|
||||||
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 SpringMVC 请求地址不存在
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(NoResourceFoundException.class)
|
||||||
|
private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
|
||||||
|
log.warn("[noResourceFoundExceptionHandler]", ex);
|
||||||
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 SpringMVC 请求方法不正确
|
* 处理 SpringMVC 请求方法不正确
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue