Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
7d0b14fe
Commit
7d0b14fe
authored
Apr 21, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x' into 2.2.x
Closes gh-21070
parents
8cbd7f5c
6011470b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
WebMvcAutoConfiguration.java
...ot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
+1
-0
WebMvcAutoConfigurationTests.java
...toconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+25
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
View file @
7d0b14fe
...
@@ -402,6 +402,7 @@ public class WebMvcAutoConfiguration {
...
@@ -402,6 +402,7 @@ public class WebMvcAutoConfiguration {
new
TemplateAvailabilityProviders
(
applicationContext
),
applicationContext
,
getWelcomePage
(),
new
TemplateAvailabilityProviders
(
applicationContext
),
applicationContext
,
getWelcomePage
(),
this
.
mvcProperties
.
getStaticPathPattern
());
this
.
mvcProperties
.
getStaticPathPattern
());
welcomePageHandlerMapping
.
setInterceptors
(
getInterceptors
(
mvcConversionService
,
mvcResourceUrlProvider
));
welcomePageHandlerMapping
.
setInterceptors
(
getInterceptors
(
mvcConversionService
,
mvcResourceUrlProvider
));
welcomePageHandlerMapping
.
setCorsConfigurations
(
getCorsConfigurations
());
return
welcomePageHandlerMapping
;
return
welcomePageHandlerMapping
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
View file @
7d0b14fe
...
@@ -76,6 +76,7 @@ import org.springframework.web.accept.ParameterContentNegotiationStrategy;
...
@@ -76,6 +76,7 @@ import org.springframework.web.accept.ParameterContentNegotiationStrategy;
import
org.springframework.web.accept.PathExtensionContentNegotiationStrategy
;
import
org.springframework.web.accept.PathExtensionContentNegotiationStrategy
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.context.request.ServletWebRequest
;
import
org.springframework.web.context.request.ServletWebRequest
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.FormContentFilter
;
import
org.springframework.web.filter.FormContentFilter
;
import
org.springframework.web.filter.HiddenHttpMethodFilter
;
import
org.springframework.web.filter.HiddenHttpMethodFilter
;
import
org.springframework.web.filter.RequestContextFilter
;
import
org.springframework.web.filter.RequestContextFilter
;
...
@@ -87,6 +88,7 @@ import org.springframework.web.servlet.View;
...
@@ -87,6 +88,7 @@ import org.springframework.web.servlet.View;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
;
import
org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
;
import
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
;
...
@@ -536,7 +538,19 @@ class WebMvcAutoConfigurationTests {
...
@@ -536,7 +538,19 @@ class WebMvcAutoConfigurationTests {
this
.
contextRunner
.
withPropertyValues
(
"spring.resources.static-locations:classpath:/welcome-page/"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.resources.static-locations:classpath:/welcome-page/"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
WelcomePageHandlerMapping
.
class
);
assertThat
(
context
).
hasSingleBean
(
WelcomePageHandlerMapping
.
class
);
assertThat
(
context
.
getBean
(
WelcomePageHandlerMapping
.
class
).
getRootHandler
()).
isNotNull
();
WelcomePageHandlerMapping
bean
=
context
.
getBean
(
WelcomePageHandlerMapping
.
class
);
assertThat
(
bean
.
getRootHandler
()).
isNotNull
();
});
}
@Test
void
welcomePageHandlerIncludesCorsConfiguration
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.resources.static-locations:classpath:/welcome-page/"
)
.
withUserConfiguration
(
CorsConfigurer
.
class
).
run
((
context
)
->
{
WelcomePageHandlerMapping
bean
=
context
.
getBean
(
WelcomePageHandlerMapping
.
class
);
UrlBasedCorsConfigurationSource
source
=
(
UrlBasedCorsConfigurationSource
)
ReflectionTestUtils
.
getField
(
bean
,
"corsConfigurationSource"
);
assertThat
(
source
.
getCorsConfigurations
()).
containsKey
(
"/**"
);
});
});
}
}
...
@@ -1157,4 +1171,14 @@ class WebMvcAutoConfigurationTests {
...
@@ -1157,4 +1171,14 @@ class WebMvcAutoConfigurationTests {
}
}
@Configuration
static
class
CorsConfigurer
implements
WebMvcConfigurer
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
).
allowedMethods
(
"GET"
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment