org.springframework.boot.web.server.ConfigurableWebServerFactory Java Examples

The following examples show how to use org.springframework.boot.web.server.ConfigurableWebServerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MvcAutoConfiguration.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
/**
 * 配置默认错误页面(仅用于内嵌tomcat启动时) 使用这种方式,在打包为war后不起作用.
 *
 * @return webServerFactoryCustomizer
 */
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
    return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
        @Override
        public void customize(ConfigurableWebServerFactory factory) {
            _logger.debug("WebServerFactoryCustomizer ... ");
            ErrorPage errorPage400 = 
                    new ErrorPage(HttpStatus.BAD_REQUEST, "/exception/error/400");
            ErrorPage errorPage404 = 
                    new ErrorPage(HttpStatus.NOT_FOUND, "/exception/error/404");
            ErrorPage errorPage500 = 
                    new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/exception/error/500");
            factory.addErrorPages(errorPage400, errorPage404, errorPage500);
        }
    };
}
 
Example #2
Source File: MossApplication.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer(){
	return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
		@Override
		public void customize(ConfigurableWebServerFactory factory) {
			factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/index.html"));
			//factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/index.html"));
		}
	};
}
 
Example #3
Source File: ErrorPagesConfig.java    From springboot-learn with MIT License 5 votes vote down vote up
/**
 * 自定义异常处理路径
 *
 * @return
 */
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
    return (container -> {
        ErrorPage error400Page = new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400");
        ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/401");
        ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/error/403");
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error/404");
        ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500");
        ErrorPage errorExPage = new ErrorPage(Throwable.class, "/error/500");
        container.addErrorPages(error400Page, error401Page, error403Page, error404Page, error500Page, errorExPage);
    });
}
 
Example #4
Source File: TarocoAuthenticationApplication.java    From Taroco with Apache License 2.0 5 votes vote down vote up
/**
 * 解决vue-router history 模式下刷新页面的404问题
 */
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer(){
    return factory -> {
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html");
        factory.addErrorPages(error404Page);
    };
}
 
Example #5
Source File: Application.java    From admin-plus with Apache License 2.0 4 votes vote down vote up
@Override
public void customize(ConfigurableWebServerFactory factory) {
    factory.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400"));
    factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500"));
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error/404"));
}
 
Example #6
Source File: ServerPortCustomizer.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void customize(ConfigurableWebServerFactory factory) {
    factory.setPort(8086);
}