SpringBoot自定义错误页面
@Configuration
public class ErrorPageConfig {
@Bean
public WebServerFactoryCustomizer webServerFactoryCustomizer() {
return (factory -> {
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, “/error/404.html”);
ErrorPage errorPage403 = new ErrorPage(HttpStatus.FORBIDDEN, “/error/403.html”);
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, “/error/404.html”);
factory.addErrorPages(errorPage404,errorPage403,errorPage500);
});
}
}
03-28
3710
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-28
07-28