1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package cn.wisenergy.chnmuseum.party.conf;//package com.cmbchina.questionnaire.conf;
//
//import org.springframework.boot.web.server.ConfigurableWebServerFactory;
//import org.springframework.boot.web.server.ErrorPage;
//import org.springframework.boot.web.server.WebServerFactoryCustomizer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpStatus;
//
//@Configuration
//public class ErrorPageConfig {
//
// /**
// * SpringBoot2.0以上版本WebServerFactoryCustomizer代替之前版本的EmbeddedWebServerFactoryCustomizerAutoConfiguration
// *
// * @return
// */
// @Bean
// public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
//// //第一种:java7 常规写法
//// return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
//// @Override
//// public void customize(ConfigurableWebServerFactory factory) {
//// ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
//// factory.addErrorPages(errorPage404);
//// }
//// };
// //第二种写法:java8 lambda写法
// return (factory -> {
// ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
// ErrorPage errorPage500 = new ErrorPage(HttpStatus.NOT_FOUND, "/500.html");
// factory.addErrorPages(errorPage404);
// factory.addErrorPages(errorPage500);
// });
// }
//
//// @Bean
//// public EmbeddedServletContainerCustomizer containerCustomizer() {
//// return new EmbeddedServletContainerCustomizer(){
//// @Override
//// public void customize(ConfigurableEmbeddedServletContainer container){
//// container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/500"));
//// container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404"));
//// }
//// };
//// }
//
//
//}