File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
boot/src/main/java/com/reajason/javaweb/boot/api Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 22
33import lombok .extern .slf4j .Slf4j ;
44import org .springframework .http .HttpStatus ;
5+ import org .springframework .http .ResponseEntity ;
56import org .springframework .web .bind .annotation .ExceptionHandler ;
67import org .springframework .web .bind .annotation .ResponseStatus ;
78import org .springframework .web .bind .annotation .RestControllerAdvice ;
9+ import org .springframework .web .servlet .resource .NoResourceFoundException ;
810
911/**
1012 * @author ReaJason
1315@ RestControllerAdvice
1416@ Slf4j
1517public 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 ) {
You can’t perform that action at this time.
0 commit comments