标签:body page 文件 oct class set erro containe 404页面
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return (container -> {
ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
container.addErrorPages(error401Page, error404Page, error500Page);
});
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404</title>
</head>
<body>
<h2>这是一个自定义的错误页面!</h2>
</body>
</html>
这样404页面就会被换为自定义的页面了.
标签:body page 文件 oct class set erro containe 404页面
原文地址:https://www.cnblogs.com/charlypage/p/9515080.html