From 43ed824f405e6a8852c776356a99d073c1fab632 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 18 Jan 2016 15:16:54 +0000 Subject: [PATCH] =?UTF-8?q?Reinstate=20Tomcat=E2=80=99s=20old=20default=20?= =?UTF-8?q?behaviour=20for=20context=20root=20redirects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to Tomcat 8.0.30, its default behaviour was for the mapper to redirect a request for context-root to context-root/. This redirection was switched off by default in 8.0.30 by default. This has proven to be problematic and Tomcat 8.0.31 will reinstate the old default. While we are waiting for Tomcat 8.0.31 to be released, this commit explicitly sets the default back to what it was in 8.0.29 and earlier and what it will be in 8.0.31. Closes gh-4937 --- .../embedded/tomcat/TomcatEmbeddedServletContainerFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java index ecafc29460..c9e1f13e6d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -169,6 +169,7 @@ public class TomcatEmbeddedServletContainerFactory : ClassUtils.getDefaultClassLoader()); try { context.setUseRelativeRedirects(false); + context.setMapperContextRootRedirectEnabled(true); } catch (NoSuchMethodError ex) { // Tomcat is < 8.0.30. Continue