This commit is contained in:
Phillip Webb
2018-02-26 10:23:23 -08:00
parent 306c79f0de
commit 29c3be3590
27 changed files with 69 additions and 67 deletions

View File

@@ -48,12 +48,14 @@ public class CloudFoundryCustomContextPathExample {
return new TomcatServletWebServerFactory() {
@Override
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
protected void prepareContext(Host host,
ServletContextInitializer[] initializers) {
super.prepareContext(host, initializers);
StandardContext child = new StandardContext();
child.addLifecycleListener(new Tomcat.FixContextListener());
child.setPath("/cloudfoundryapplication");
ServletContainerInitializer initializer = getServletContextInitializer(getContextPath());
ServletContainerInitializer initializer = getServletContextInitializer(
getContextPath());
child.addServletContainerInitializer(initializer, Collections.emptySet());
child.setCrossContext(true);
host.addChild(child);
@@ -69,8 +71,10 @@ public class CloudFoundryCustomContextPathExample {
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
ServletContext context = req.getServletContext().getContext(contextPath);
context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res);
ServletContext context = req.getServletContext()
.getContext(contextPath);
context.getRequestDispatcher("/cloudfoundryapplication").forward(req,
res);
}
};