From 171dea5525273a5bb9052a7097be7363b1951a39 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Thu, 18 Apr 2024 01:45:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/skcks/wx/official/api/advice/ExceptionAdvice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wx-official-api/src/main/java/cn/skcks/wx/official/api/advice/ExceptionAdvice.java b/wx-official-api/src/main/java/cn/skcks/wx/official/api/advice/ExceptionAdvice.java index 42dc24b..f4899d6 100644 --- a/wx-official-api/src/main/java/cn/skcks/wx/official/api/advice/ExceptionAdvice.java +++ b/wx-official-api/src/main/java/cn/skcks/wx/official/api/advice/ExceptionAdvice.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.context.request.async.AsyncRequestTimeoutException; +import org.springframework.web.servlet.resource.NoResourceFoundException; import java.util.Objects; @@ -83,6 +84,11 @@ public class ExceptionAdvice { return JsonResponse.error("请求超时"); } + @ExceptionHandler(NoResourceFoundException.class) + public JsonResponse exception(NoResourceFoundException e) { + return JsonResponse.error(e.getMessage()); + } + @ExceptionHandler(NullPointerException.class) public JsonResponse exception(NullPointerException e) { e.printStackTrace();