From a95494fe61221a3f51f29da32a30595c676a7ce2 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 23 Aug 2013 09:59:40 -0700 Subject: [PATCH] Remove '/resources/**' mapping and default servlet Remove '/resources/**' mapping since it can cause problems with the '/**' when the developer defines their own 'resources' sub-folder. Also remove default servlet config since the resources mapping renders it redundant. Issue: #55494446 --- .../boot/autoconfigure/web/WebMvcAutoConfiguration.java | 9 --------- .../src/main/resources/templates/error.html | 6 +++--- .../src/main/resources/templates/home.html | 6 +++--- .../boot/sample/ui/SampleWebStaticApplicationTests.java | 4 ++-- .../src/main/resources/templates/layout.html | 6 +++--- .../boot/sample/ui/SampleWebUiApplicationTests.java | 4 ++-- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index a92a03af121..d7649be5be9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -48,7 +48,6 @@ import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.filter.HiddenHttpMethodFilter; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.View; -import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; @@ -145,12 +144,6 @@ public class WebMvcAutoConfiguration { return resolver; } - @Override - public void configureDefaultServletHandling( - DefaultServletHandlerConfigurer configurer) { - configurer.enable(); - } - @Override public void addFormatters(FormatterRegistry registry) { for (Converter converter : getBeansOfType(Converter.class)) { @@ -172,8 +165,6 @@ public class WebMvcAutoConfiguration { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/resources/**").addResourceLocations( - RESOURCE_LOCATIONS); registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); } diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.html b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.html index 9cba172064c..baa9677cac5 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.html +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.html @@ -2,8 +2,8 @@ Error - +
@@ -28,4 +28,4 @@
- \ No newline at end of file + diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.html b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.html index 3d314f4214d..2ec60a60dab 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.html +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.html @@ -2,8 +2,8 @@ Title - +
@@ -22,4 +22,4 @@ 2012 2:17:16 PM CDT
- \ No newline at end of file + diff --git a/spring-boot-samples/spring-boot-sample-web-static/src/test/java/org/springframework/boot/sample/ui/SampleWebStaticApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-static/src/test/java/org/springframework/boot/sample/ui/SampleWebStaticApplicationTests.java index abd1ecad1d4..c39f4d46697 100644 --- a/spring-boot-samples/spring-boot-sample-web-static/src/test/java/org/springframework/boot/sample/ui/SampleWebStaticApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-static/src/test/java/org/springframework/boot/sample/ui/SampleWebStaticApplicationTests.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; /** * Basic integration tests for demo application. - * + * * @author Dave Syer */ public class SampleWebStaticApplicationTests { @@ -63,7 +63,7 @@ public class SampleWebStaticApplicationTests { @Test public void testCss() throws Exception { ResponseEntity entity = getRestTemplate().getForEntity( - "http://localhost:8080/resources/css/bootstrap.min.css", String.class); + "http://localhost:8080/css/bootstrap.min.css", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(), diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/layout.html b/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/layout.html index a1a8ce2c378..1263f6d9e36 100644 --- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/layout.html +++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/layout.html @@ -3,8 +3,8 @@ Layout + th:href="@{/css/bootstrap.min.css}" + href="../../css/bootstrap.min.css"/>
@@ -29,4 +29,4 @@
- \ No newline at end of file + diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/org/springframework/boot/sample/ui/SampleWebUiApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/org/springframework/boot/sample/ui/SampleWebUiApplicationTests.java index 4be487bd8dd..3bc91f01fd2 100644 --- a/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/org/springframework/boot/sample/ui/SampleWebUiApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-ui/src/test/java/org/springframework/boot/sample/ui/SampleWebUiApplicationTests.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; /** * Basic integration tests for demo application. - * + * * @author Dave Syer */ public class SampleWebUiApplicationTests { @@ -78,7 +78,7 @@ public class SampleWebUiApplicationTests { @Test public void testCss() throws Exception { ResponseEntity entity = getRestTemplate().getForEntity( - "http://localhost:8080/resources/css/bootstrap.min.css", String.class); + "http://localhost:8080/css/bootstrap.min.css", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); }