mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-05-03 03:43:54 +01:00
Merge branch '1.4.x' into 1.5.x
This commit is contained in:
+5
-3
@@ -300,7 +300,8 @@ public class WebMvcAutoConfiguration {
|
||||
@Bean
|
||||
public WelcomePageHandlerMapping welcomePageHandlerMapping(
|
||||
ResourceProperties resourceProperties) {
|
||||
return new WelcomePageHandlerMapping(resourceProperties.getWelcomePage());
|
||||
return new WelcomePageHandlerMapping(resourceProperties.getWelcomePage(),
|
||||
this.mvcProperties.getStaticPathPattern());
|
||||
}
|
||||
|
||||
private void customizeResourceHandlerRegistration(
|
||||
@@ -520,8 +521,9 @@ public class WebMvcAutoConfiguration {
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(WelcomePageHandlerMapping.class);
|
||||
|
||||
private WelcomePageHandlerMapping(Resource welcomePage) {
|
||||
if (welcomePage != null) {
|
||||
private WelcomePageHandlerMapping(Resource welcomePage,
|
||||
String staticPathPattern) {
|
||||
if (welcomePage != null && "/**".equals(staticPathPattern)) {
|
||||
logger.info("Adding welcome page: " + welcomePage);
|
||||
ParameterizableViewController controller = new ParameterizableViewController();
|
||||
controller.setViewName("forward:index.html");
|
||||
|
||||
+9
@@ -569,6 +569,15 @@ public class WebMvcAutoConfigurationTests {
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void welcomePageRootHandlerIsNotRegisteredWhenStaticPathPatternIsNotSlashStarStar() {
|
||||
load("spring.resources.static-locations:classpath:/welcome-page/",
|
||||
"spring.mvc.static-path-pattern:/foo/**");
|
||||
WelcomePageHandlerMapping welcomePageHandlerMapping = this.context
|
||||
.getBean(WelcomePageHandlerMapping.class);
|
||||
assertThat(welcomePageHandlerMapping.getRootHandler()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void welcomePageMappingHandlesRequestsThatAcceptTextHtml() throws Exception {
|
||||
load("spring.resources.static-locations:classpath:/welcome-page/");
|
||||
|
||||
Reference in New Issue
Block a user