Spring boot customizes 404 error page @ ControllerAdvice mode

other errors will enter here, but 404 errors will not come in? Online documents and articles all say that this is the way to play. It"s really strange.

The

404 page keeps reporting this error without entering my custom settings
* Whitelabel Error Page
This application has no explicit mapping for / error, so you are seeing this as a fallback.
Sun Jun 03 11:50:14 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available**

@ControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    public static final String DEFAULT_ERROR_VIEW = "error/400";

    @ExceptionHandler(value = Exception.class)
    public ModelAndView defaultErrorHandler(HttpServletRequest request, Exception e) {
        logger.info("", e);
        ModelAndView m = new ModelAndView();
        m.addObject("exception", e);
        m.addObject("url", request.getRequestURL());
        m.setViewName(DEFAULT_ERROR_VIEW);
        return m;
    }
}    

if configured, 404 can be captured

< H1 > throw an exception directly when an error occurs < / H1 >

spring.mvc.throw-exception-if-no-handler-found=true

< H1 > do not establish a mapping for the resource files in our project < / H1 >

spring.resources.add-mappings=false

but nothing like css js can be accessed.

Mar.16,2021

  public static final String DEFAULT_ERROR_VIEW = "error/400";

check the path and the location of the page


re-implement ErrorController. Baidu knows at a glance that


sends a request that does not exist by default, which will be forwarded to / ${context-path} / error
and will not be intercepted by ControllerAdvice

.
Menu