Commit 859b2663 authored by Phillip Webb's avatar Phillip Webb

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
parent e55fc944
...@@ -48,7 +48,6 @@ import org.springframework.web.accept.ContentNegotiationManager; ...@@ -48,7 +48,6 @@ import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.filter.HiddenHttpMethodFilter; import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.View; 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.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
...@@ -145,12 +144,6 @@ public class WebMvcAutoConfiguration { ...@@ -145,12 +144,6 @@ public class WebMvcAutoConfiguration {
return resolver; return resolver;
} }
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override @Override
public void addFormatters(FormatterRegistry registry) { public void addFormatters(FormatterRegistry registry) {
for (Converter<?, ?> converter : getBeansOfType(Converter.class)) { for (Converter<?, ?> converter : getBeansOfType(Converter.class)) {
...@@ -172,8 +165,6 @@ public class WebMvcAutoConfiguration { ...@@ -172,8 +165,6 @@ public class WebMvcAutoConfiguration {
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations(
RESOURCE_LOCATIONS);
registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS);
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<html xmlns:th="http://www.thymeleaf.org"> <html xmlns:th="http://www.thymeleaf.org">
<head> <head>
<title>Error</title> <title>Error</title>
<link rel="stylesheet" th:href="@{/resources/css/bootstrap.min.css}" <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"
href="../../resources/css/bootstrap.min.css" /> href="../../css/bootstrap.min.css" />
</head> </head>
<body> <body>
<div class="container"> <div class="container">
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<html xmlns:th="http://www.thymeleaf.org"> <html xmlns:th="http://www.thymeleaf.org">
<head> <head>
<title th:text="${title}">Title</title> <title th:text="${title}">Title</title>
<link rel="stylesheet" th:href="@{/resources/css/bootstrap.min.css}" <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"
href="../../resources/css/bootstrap.min.css" /> href="../../css/bootstrap.min.css" />
</head> </head>
<body> <body>
<div class="container"> <div class="container">
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
2012 2:17:16 PM CDT</div> 2012 2:17:16 PM CDT</div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; ...@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* Basic integration tests for demo application. * Basic integration tests for demo application.
* *
* @author Dave Syer * @author Dave Syer
*/ */
public class SampleWebStaticApplicationTests { public class SampleWebStaticApplicationTests {
...@@ -63,7 +63,7 @@ public class SampleWebStaticApplicationTests { ...@@ -63,7 +63,7 @@ public class SampleWebStaticApplicationTests {
@Test @Test
public void testCss() throws Exception { public void testCss() throws Exception {
ResponseEntity<String> entity = getRestTemplate().getForEntity( ResponseEntity<String> 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()); assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(), assertEquals("Wrong content type:\n" + entity.getHeaders().getContentType(),
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<head> <head>
<title>Layout</title> <title>Layout</title>
<link rel="stylesheet" <link rel="stylesheet"
th:href="@{/resources/css/bootstrap.min.css}" th:href="@{/css/bootstrap.min.css}"
href="../../resources/css/bootstrap.min.css"/> href="../../css/bootstrap.min.css"/>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
...@@ -29,4 +29,4 @@ ...@@ -29,4 +29,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; ...@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* Basic integration tests for demo application. * Basic integration tests for demo application.
* *
* @author Dave Syer * @author Dave Syer
*/ */
public class SampleWebUiApplicationTests { public class SampleWebUiApplicationTests {
...@@ -78,7 +78,7 @@ public class SampleWebUiApplicationTests { ...@@ -78,7 +78,7 @@ public class SampleWebUiApplicationTests {
@Test @Test
public void testCss() throws Exception { public void testCss() throws Exception {
ResponseEntity<String> entity = getRestTemplate().getForEntity( ResponseEntity<String> 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()); assertEquals(HttpStatus.OK, entity.getStatusCode());
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body")); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment