Skip to content

Commit 5ea3cf0

Browse files
committed
fix: skip no static resource exception
1 parent f453d49 commit 5ea3cf0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

boot/src/main/java/com/reajason/javaweb/boot/api/GlobalExceptionHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.springframework.http.HttpStatus;
5+
import org.springframework.http.ResponseEntity;
56
import org.springframework.web.bind.annotation.ExceptionHandler;
67
import org.springframework.web.bind.annotation.ResponseStatus;
78
import org.springframework.web.bind.annotation.RestControllerAdvice;
9+
import org.springframework.web.servlet.resource.NoResourceFoundException;
810

911
/**
1012
* @author ReaJason
@@ -13,6 +15,13 @@
1315
@RestControllerAdvice
1416
@Slf4j
1517
public class GlobalExceptionHandler {
18+
19+
@ResponseStatus(HttpStatus.NOT_FOUND)
20+
@ExceptionHandler(NoResourceFoundException.class)
21+
public ResponseEntity<?> handleNoResourceException() {
22+
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
23+
}
24+
1625
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
1726
@ExceptionHandler(Throwable.class)
1827
public ErrorResponse handleThrowable(Throwable throwable) {

0 commit comments

Comments
 (0)