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
ab01c55d
Commit
ab01c55d
authored
Mar 26, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate use of path extensions for request mapping and content negotiation
Closes gh-20528
parent
0c3be4dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
3 deletions
+23
-3
WebMvcAutoConfiguration.java
...ot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
+3
-1
WebMvcProperties.java
...work/boot/autoconfigure/web/servlet/WebMvcProperties.java
+14
-1
WebMvcAutoConfigurationTests.java
...toconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+5
-1
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
View file @
ab01c55d
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -220,6 +220,7 @@ public class WebMvcAutoConfiguration {
...
@@ -220,6 +220,7 @@ public class WebMvcAutoConfiguration {
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
configurer
.
setUseSuffixPatternMatch
(
this
.
mvcProperties
.
getPathmatch
().
isUseSuffixPattern
());
configurer
.
setUseSuffixPatternMatch
(
this
.
mvcProperties
.
getPathmatch
().
isUseSuffixPattern
());
configurer
.
setUseRegisteredSuffixPatternMatch
(
configurer
.
setUseRegisteredSuffixPatternMatch
(
...
@@ -227,6 +228,7 @@ public class WebMvcAutoConfiguration {
...
@@ -227,6 +228,7 @@ public class WebMvcAutoConfiguration {
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
WebMvcProperties
.
Contentnegotiation
contentnegotiation
=
this
.
mvcProperties
.
getContentnegotiation
();
WebMvcProperties
.
Contentnegotiation
contentnegotiation
=
this
.
mvcProperties
.
getContentnegotiation
();
configurer
.
favorPathExtension
(
contentnegotiation
.
isFavorPathExtension
());
configurer
.
favorPathExtension
(
contentnegotiation
.
isFavorPathExtension
());
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java
View file @
ab01c55d
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,6 +22,7 @@ import java.util.Locale;
...
@@ -22,6 +22,7 @@ import java.util.Locale;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.DeprecatedConfigurationProperty
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.DefaultMessageCodesResolver
;
import
org.springframework.validation.DefaultMessageCodesResolver
;
...
@@ -352,10 +353,14 @@ public class WebMvcProperties {
...
@@ -352,10 +353,14 @@ public class WebMvcProperties {
*/
*/
private
String
parameterName
;
private
String
parameterName
;
@DeprecatedConfigurationProperty
(
reason
=
"Use of path extensions for request mapping and for content negotiation is discouraged."
)
@Deprecated
public
boolean
isFavorPathExtension
()
{
public
boolean
isFavorPathExtension
()
{
return
this
.
favorPathExtension
;
return
this
.
favorPathExtension
;
}
}
@Deprecated
public
void
setFavorPathExtension
(
boolean
favorPathExtension
)
{
public
void
setFavorPathExtension
(
boolean
favorPathExtension
)
{
this
.
favorPathExtension
=
favorPathExtension
;
this
.
favorPathExtension
=
favorPathExtension
;
}
}
...
@@ -402,18 +407,26 @@ public class WebMvcProperties {
...
@@ -402,18 +407,26 @@ public class WebMvcProperties {
*/
*/
private
boolean
useRegisteredSuffixPattern
=
false
;
private
boolean
useRegisteredSuffixPattern
=
false
;
@DeprecatedConfigurationProperty
(
reason
=
"Use of path extensions for request mapping and for content negotiation is discouraged."
)
@Deprecated
public
boolean
isUseSuffixPattern
()
{
public
boolean
isUseSuffixPattern
()
{
return
this
.
useSuffixPattern
;
return
this
.
useSuffixPattern
;
}
}
@Deprecated
public
void
setUseSuffixPattern
(
boolean
useSuffixPattern
)
{
public
void
setUseSuffixPattern
(
boolean
useSuffixPattern
)
{
this
.
useSuffixPattern
=
useSuffixPattern
;
this
.
useSuffixPattern
=
useSuffixPattern
;
}
}
@DeprecatedConfigurationProperty
(
reason
=
"Use of path extensions for request mapping and for content negotiation is discouraged."
)
@Deprecated
public
boolean
isUseRegisteredSuffixPattern
()
{
public
boolean
isUseRegisteredSuffixPattern
()
{
return
this
.
useRegisteredSuffixPattern
;
return
this
.
useRegisteredSuffixPattern
;
}
}
@Deprecated
public
void
setUseRegisteredSuffixPattern
(
boolean
useRegisteredSuffixPattern
)
{
public
void
setUseRegisteredSuffixPattern
(
boolean
useRegisteredSuffixPattern
)
{
this
.
useRegisteredSuffixPattern
=
useRegisteredSuffixPattern
;
this
.
useRegisteredSuffixPattern
=
useRegisteredSuffixPattern
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
View file @
ab01c55d
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -432,6 +432,7 @@ class WebMvcAutoConfigurationTests {
...
@@ -432,6 +432,7 @@ class WebMvcAutoConfigurationTests {
}
}
@Test
@Test
@Deprecated
void
customMediaTypes
()
{
void
customMediaTypes
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.media-types.yaml:text/yaml"
,
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.media-types.yaml:text/yaml"
,
"spring.mvc.contentnegotiation.favor-path-extension:true"
).
run
((
context
)
->
{
"spring.mvc.contentnegotiation.favor-path-extension:true"
).
run
((
context
)
->
{
...
@@ -687,6 +688,7 @@ class WebMvcAutoConfigurationTests {
...
@@ -687,6 +688,7 @@ class WebMvcAutoConfigurationTests {
}
}
@Test
@Test
@Deprecated
void
useSuffixPatternMatch
()
{
void
useSuffixPatternMatch
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.pathmatch.use-suffix-pattern:true"
,
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.pathmatch.use-suffix-pattern:true"
,
"spring.mvc.pathmatch.use-registered-suffix-pattern:true"
).
run
((
context
)
->
{
"spring.mvc.pathmatch.use-registered-suffix-pattern:true"
).
run
((
context
)
->
{
...
@@ -707,6 +709,7 @@ class WebMvcAutoConfigurationTests {
...
@@ -707,6 +709,7 @@ class WebMvcAutoConfigurationTests {
}
}
@Test
@Test
@Deprecated
void
pathExtensionContentNegotiation
()
{
void
pathExtensionContentNegotiation
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.favor-path-extension:true"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.favor-path-extension:true"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
...
@@ -718,6 +721,7 @@ class WebMvcAutoConfigurationTests {
...
@@ -718,6 +721,7 @@ class WebMvcAutoConfigurationTests {
}
}
@Test
@Test
@Deprecated
void
queryParameterContentNegotiation
()
{
void
queryParameterContentNegotiation
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.favor-parameter:true"
).
run
((
context
)
->
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.contentnegotiation.favor-parameter:true"
).
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
ab01c55d
...
@@ -2211,6 +2211,7 @@ Instead of using suffix matching, we can use a query parameter to ensure that re
...
@@ -2211,6 +2211,7 @@ Instead of using suffix matching, we can use a query parameter to ensure that re
spring.mvc.contentnegotiation.media-types.markdown=text/markdown
spring.mvc.contentnegotiation.media-types.markdown=text/markdown
----
----
Suffix pattern matching is deprecated and will be removed in a future release.
If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required:
If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required:
[source,properties,indent=0,subs="verbatim,quotes,attributes",configprops]
[source,properties,indent=0,subs="verbatim,quotes,attributes",configprops]
...
...
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