@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 页面,求助~
PHP中文网2017-04-17 17:57:43
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.