java - Spring Boot 异常页面配置问题
巴扎黑
巴扎黑 2017-04-17 17:55:43
0
1
243
@Configuration
public class WebConfig {

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
 
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404");
                container.addErrorPages(error404Page);
            }
        };
    }
}

404所在位置:

P.S 这样配置的话,系统无法正常跳转到指定 404 页面,求助~

巴扎黑
巴扎黑

reply all(1)
Ty80

SOLVED:
The reason is
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404");

Unable to route to the specified page, you need to define a controller and use SpringMVC's DispatcherServlet to distribute routing to the specified page.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template