From 2a5d7cbc646a7b38e5bef86da0b0df0eda66d058 Mon Sep 17 00:00:00 2001 From: sdw086 Date: Tue, 10 Mar 2026 17:58:40 +0900 Subject: [PATCH] =?UTF-8?q?[File]=20=ED=8C=8C=EB=B9=84=EC=BD=98=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=95=A0=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alist/api/common/response/ApiResponseCode.java | 1 + .../config/exception/GlobalExceptionHandler.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/com/alist/api/common/response/ApiResponseCode.java b/src/main/java/com/alist/api/common/response/ApiResponseCode.java index 71da6ef..44bec1f 100644 --- a/src/main/java/com/alist/api/common/response/ApiResponseCode.java +++ b/src/main/java/com/alist/api/common/response/ApiResponseCode.java @@ -7,6 +7,7 @@ import java.text.MessageFormat; public enum ApiResponseCode { // ===== Common ===== CODE_200 ("200", "성공", HttpStatus.OK), + CODE_204 ("204", "컨텐츠 없음", HttpStatus.NO_CONTENT), CODE_400 ("400", "잘못된 요청", HttpStatus.BAD_REQUEST), CODE_401 ("401", "인증 필요 합니다.", HttpStatus.UNAUTHORIZED), diff --git a/src/main/java/com/alist/api/config/exception/GlobalExceptionHandler.java b/src/main/java/com/alist/api/config/exception/GlobalExceptionHandler.java index e3f6cc6..7340656 100644 --- a/src/main/java/com/alist/api/config/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/alist/api/config/exception/GlobalExceptionHandler.java @@ -14,6 +14,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.method.annotation.MethodArgumentTypeMismatchException; +import org.springframework.web.servlet.resource.NoResourceFoundException; import java.util.LinkedHashMap; import java.util.Map; @@ -102,4 +103,17 @@ public class GlobalExceptionHandler { return ApiResponse.entity(ApiResponseCode.CODE_500); } + + @ExceptionHandler(NoResourceFoundException.class) + public ResponseEntity> handleNoResourceFound(NoResourceFoundException e) { + String resourcePath = e.getResourcePath(); + + if ("favicon.ico".equals(resourcePath) || "/favicon.ico".equals(resourcePath)) { + return ApiResponse.entity(ApiResponseCode.CODE_204); + } + + log.error("Unhandled exception occurred", e); + + return ApiResponse.entity(ApiResponseCode.CODE_404); + } }