diff --git a/nflg-wms-starter/src/main/java/com/nflg/wms/starter/advice/GlobalRestControllerAdvice.java b/nflg-wms-starter/src/main/java/com/nflg/wms/starter/advice/GlobalRestControllerAdvice.java index 6ac01d8f..6976370c 100644 --- a/nflg-wms-starter/src/main/java/com/nflg/wms/starter/advice/GlobalRestControllerAdvice.java +++ b/nflg-wms-starter/src/main/java/com/nflg/wms/starter/advice/GlobalRestControllerAdvice.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.resource.NoResourceFoundException; import java.util.ArrayList; import java.util.List; @@ -66,4 +67,11 @@ public class GlobalRestControllerAdvice { public String handleNotLoginException(NotLoginException e) { return "请重新登录"; } + + @ExceptionHandler(NoResourceFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ApiResult handleNoResourceFoundException(NoResourceFoundException ex) { + log.error("请求的地址无效: ", ex); + return ApiResult.error(STATE.BusinessError, "请求的地址无效:" + ex.getResourcePath()); + } } \ No newline at end of file