List of usage examples for org.springframework.boot.web.servlet.server ServletWebServerFactory getWebServer
WebServer getWebServer(ServletContextInitializer... initializers);
From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java
protected void assertForwardHeaderIsUsed(ServletWebServerFactory factory) throws IOException, URISyntaxException { this.webServer = factory .getWebServer(new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello")); this.webServer.start(); assertThat(getResponse(getLocalUrl("/hello"), "X-Forwarded-For:140.211.11.130")) .contains("remoteaddr=140.211.11.130"); }
From source file:org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.java
private void createWebServer() { WebServer webServer = this.webServer; ServletContext servletContext = getServletContext(); if (webServer == null && servletContext == null) { ServletWebServerFactory factory = getWebServerFactory(); this.webServer = factory.getWebServer(getSelfInitializer()); } else if (servletContext != null) { try {/*ww w . ja v a 2 s . c om*/ getSelfInitializer().onStartup(servletContext); } catch (ServletException ex) { throw new ApplicationContextException("Cannot initialize servlet context", ex); } } initPropertySources(); }