Remove - from path-match and content-negotiation properties
Closes gh-11913
This commit is contained in:
parent
83f65a38b1
commit
9a456924e4
|
@ -218,21 +218,21 @@ public class WebMvcAutoConfiguration {
|
||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
configurer.setUseSuffixPatternMatch(
|
configurer.setUseSuffixPatternMatch(
|
||||||
this.mvcProperties.getPathMatch().isUseSuffixPattern());
|
this.mvcProperties.getPathmatch().isUseSuffixPattern());
|
||||||
configurer.setUseRegisteredSuffixPatternMatch(
|
configurer.setUseRegisteredSuffixPatternMatch(
|
||||||
this.mvcProperties.getPathMatch().isUseRegisteredSuffixPattern());
|
this.mvcProperties.getPathmatch().isUseRegisteredSuffixPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||||
WebMvcProperties.ContentNegotiation contentNegotiation = this.mvcProperties
|
WebMvcProperties.Contentnegotiation contentnegotiation = this.mvcProperties
|
||||||
.getContentNegotiation();
|
.getContentnegotiation();
|
||||||
configurer.favorPathExtension(contentNegotiation.isFavorPathExtension());
|
configurer.favorPathExtension(contentnegotiation.isFavorPathExtension());
|
||||||
configurer.favorParameter(contentNegotiation.isFavorParameter());
|
configurer.favorParameter(contentnegotiation.isFavorParameter());
|
||||||
if (contentNegotiation.getParameterName() != null) {
|
if (contentnegotiation.getParameterName() != null) {
|
||||||
configurer.parameterName(contentNegotiation.getParameterName());
|
configurer.parameterName(contentnegotiation.getParameterName());
|
||||||
}
|
}
|
||||||
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentNegotiation()
|
Map<String, MediaType> mediaTypes = this.mvcProperties.getContentnegotiation()
|
||||||
.getMediaTypes();
|
.getMediaTypes();
|
||||||
for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
|
for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
|
||||||
configurer.mediaType(mediaType.getKey(), mediaType.getValue());
|
configurer.mediaType(mediaType.getKey(), mediaType.getValue());
|
||||||
|
|
|
@ -98,9 +98,9 @@ public class WebMvcProperties {
|
||||||
|
|
||||||
private final View view = new View();
|
private final View view = new View();
|
||||||
|
|
||||||
private final ContentNegotiation contentNegotiation = new ContentNegotiation();
|
private final Contentnegotiation contentnegotiation = new Contentnegotiation();
|
||||||
|
|
||||||
private final PathMatch pathMatch = new PathMatch();
|
private final Pathmatch pathmatch = new Pathmatch();
|
||||||
|
|
||||||
public DefaultMessageCodesResolver.Format getMessageCodesResolverFormat() {
|
public DefaultMessageCodesResolver.Format getMessageCodesResolverFormat() {
|
||||||
return this.messageCodesResolverFormat;
|
return this.messageCodesResolverFormat;
|
||||||
|
@ -196,12 +196,12 @@ public class WebMvcProperties {
|
||||||
return this.view;
|
return this.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentNegotiation getContentNegotiation() {
|
public Contentnegotiation getContentnegotiation() {
|
||||||
return this.contentNegotiation;
|
return this.contentnegotiation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathMatch getPathMatch() {
|
public Pathmatch getPathmatch() {
|
||||||
return this.pathMatch;
|
return this.pathmatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Async {
|
public static class Async {
|
||||||
|
@ -270,7 +270,7 @@ public class WebMvcProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ContentNegotiation {
|
public static class Contentnegotiation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the path extension in the URL path should be used to determine the
|
* Whether the path extension in the URL path should be used to determine the
|
||||||
|
@ -330,7 +330,7 @@ public class WebMvcProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PathMatch {
|
public static class Pathmatch {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to use suffix pattern match (".*") when matching patterns to requests.
|
* Whether to use suffix pattern match (".*") when matching patterns to requests.
|
||||||
|
|
|
@ -414,7 +414,7 @@
|
||||||
"type" : "java.util.Map<java.lang.String,org.springframework.http.MediaType>",
|
"type" : "java.util.Map<java.lang.String,org.springframework.http.MediaType>",
|
||||||
"description" : "Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.",
|
"description" : "Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.",
|
||||||
"deprecation" : {
|
"deprecation" : {
|
||||||
"replacement" : "spring.mvc.content-negotiation.media-types",
|
"replacement" : "spring.mvc.contentnegotiation.media-types",
|
||||||
"level" : "error"
|
"level" : "error"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -473,8 +473,8 @@ public class WebMvcAutoConfigurationTests {
|
||||||
public void customMediaTypes() {
|
public void customMediaTypes() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withPropertyValues(
|
.withPropertyValues(
|
||||||
"spring.mvc.content-negotiation.media-types.yaml:text/yaml",
|
"spring.mvc.contentnegotiation.media-types.yaml:text/yaml",
|
||||||
"spring.mvc.content-negotiation.favor-path-extension:true")
|
"spring.mvc.contentnegotiation.favor-path-extension:true")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
RequestMappingHandlerAdapter adapter = context
|
RequestMappingHandlerAdapter adapter = context
|
||||||
.getBean(RequestMappingHandlerAdapter.class);
|
.getBean(RequestMappingHandlerAdapter.class);
|
||||||
|
@ -755,8 +755,8 @@ public class WebMvcAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void useSuffixPatternMatch() {
|
public void useSuffixPatternMatch() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withPropertyValues("spring.mvc.path-match.use-suffix-pattern:true",
|
.withPropertyValues("spring.mvc.pathmatch.use-suffix-pattern:true",
|
||||||
"spring.mvc.path-match.use-registered-suffix-pattern:true")
|
"spring.mvc.pathmatch.use-registered-suffix-pattern:true")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
RequestMappingHandlerMapping handlerMapping = context
|
RequestMappingHandlerMapping handlerMapping = context
|
||||||
.getBean(RequestMappingHandlerMapping.class);
|
.getBean(RequestMappingHandlerMapping.class);
|
||||||
|
@ -782,7 +782,7 @@ public class WebMvcAutoConfigurationTests {
|
||||||
public void pathExtensionContentNegotiation() {
|
public void pathExtensionContentNegotiation() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withPropertyValues(
|
.withPropertyValues(
|
||||||
"spring.mvc.content-negotiation.favor-path-extension:true")
|
"spring.mvc.contentnegotiation.favor-path-extension:true")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
RequestMappingHandlerMapping handlerMapping = context
|
RequestMappingHandlerMapping handlerMapping = context
|
||||||
.getBean(RequestMappingHandlerMapping.class);
|
.getBean(RequestMappingHandlerMapping.class);
|
||||||
|
@ -797,7 +797,7 @@ public class WebMvcAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void queryParameterContentNegotiation() {
|
public void queryParameterContentNegotiation() {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withPropertyValues("spring.mvc.content-negotiation.favor-parameter:true")
|
.withPropertyValues("spring.mvc.contentnegotiation.favor-parameter:true")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
RequestMappingHandlerMapping handlerMapping = context
|
RequestMappingHandlerMapping handlerMapping = context
|
||||||
.getBean(RequestMappingHandlerMapping.class);
|
.getBean(RequestMappingHandlerMapping.class);
|
||||||
|
|
|
@ -396,10 +396,10 @@ content into your application. Rather, pick only the properties that you need.
|
||||||
|
|
||||||
# SPRING MVC ({sc-spring-boot-autoconfigure}/web/servlet/WebMvcProperties.{sc-ext}[WebMvcProperties])
|
# SPRING MVC ({sc-spring-boot-autoconfigure}/web/servlet/WebMvcProperties.{sc-ext}[WebMvcProperties])
|
||||||
spring.mvc.async.request-timeout= # Amount of time before asynchronous request handling times out.
|
spring.mvc.async.request-timeout= # Amount of time before asynchronous request handling times out.
|
||||||
spring.mvc.content-negotiation.favor-parameter=false # Whether a request parameter ("format" by default) should be used to determine the requested media type.
|
spring.mvc.contentnegotiation.favor-parameter=false # Whether a request parameter ("format" by default) should be used to determine the requested media type.
|
||||||
spring.mvc.content-negotiation.favor-path-extension=false # Whether the path extension in the URL path should be used to determine the requested media type.
|
spring.mvc.contentnegotiation.favor-path-extension=false # Whether the path extension in the URL path should be used to determine the requested media type.
|
||||||
spring.mvc.content-negotiation.media-types.*= # Maps file extensions to media types for content negotiation.
|
spring.mvc.contentnegotiation.media-types.*= # Maps file extensions to media types for content negotiation.
|
||||||
spring.mvc.content-negotiation.parameter-name= # Query parameter name to use when "favor-parameter" is enabled.
|
spring.mvc.contentnegotiation.parameter-name= # Query parameter name to use when "favor-parameter" is enabled.
|
||||||
spring.mvc.date-format= # Date format to use. For instance, `dd/MM/yyyy`.
|
spring.mvc.date-format= # Date format to use. For instance, `dd/MM/yyyy`.
|
||||||
spring.mvc.dispatch-trace-request=false # Whether to dispatch TRACE requests to the FrameworkServlet doService method.
|
spring.mvc.dispatch-trace-request=false # Whether to dispatch TRACE requests to the FrameworkServlet doService method.
|
||||||
spring.mvc.dispatch-options-request=true # Whether to dispatch OPTIONS requests to the FrameworkServlet doService method.
|
spring.mvc.dispatch-options-request=true # Whether to dispatch OPTIONS requests to the FrameworkServlet doService method.
|
||||||
|
@ -410,8 +410,8 @@ content into your application. Rather, pick only the properties that you need.
|
||||||
spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved.
|
spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved.
|
||||||
spring.mvc.log-resolved-exception=false # Whether to enable warn logging of exceptions resolved by a "HandlerExceptionResolver".
|
spring.mvc.log-resolved-exception=false # Whether to enable warn logging of exceptions resolved by a "HandlerExceptionResolver".
|
||||||
spring.mvc.message-codes-resolver-format= # Formatting strategy for message codes. For instance, `PREFIX_ERROR_CODE`.
|
spring.mvc.message-codes-resolver-format= # Formatting strategy for message codes. For instance, `PREFIX_ERROR_CODE`.
|
||||||
spring.mvc.path-match.use-registered-suffix-pattern=false # Whether suffix pattern matching should work only against extensions registered with "spring.mvc.content-negotiation.media-types.*".
|
spring.mvc.pathmatch.use-registered-suffix-pattern=false # Whether suffix pattern matching should work only against extensions registered with "spring.mvc.contentnegotiation.media-types.*".
|
||||||
spring.mvc.path-match.use-suffix-pattern=false # Whether to use suffix pattern match (".*") when matching patterns to requests.
|
spring.mvc.pathmatch.use-suffix-pattern=false # Whether to use suffix pattern match (".*") when matching patterns to requests.
|
||||||
spring.mvc.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet.
|
spring.mvc.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet.
|
||||||
spring.mvc.static-path-pattern=/** # Path pattern used for static resources.
|
spring.mvc.static-path-pattern=/** # Path pattern used for static resources.
|
||||||
spring.mvc.throw-exception-if-no-handler-found=false # Whether a "NoHandlerFoundException" should be thrown if no Handler was found to process a request.
|
spring.mvc.throw-exception-if-no-handler-found=false # Whether a "NoHandlerFoundException" should be thrown if no Handler was found to process a request.
|
||||||
|
|
|
@ -2076,13 +2076,13 @@ will be mapped to `@GetMapping("/projects/spring-boot")`:
|
||||||
|
|
||||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||||
----
|
----
|
||||||
spring.mvc.content-negotiation.favor-parameter=true
|
spring.mvc.contentnegotiation.favor-parameter=true
|
||||||
|
|
||||||
# We can change the parameter name, which is "format" by default:
|
# We can change the parameter name, which is "format" by default:
|
||||||
# spring.mvc.content-negotiation.parameter-name=myparam
|
# spring.mvc.contentnegotiation.parameter-name=myparam
|
||||||
|
|
||||||
# We can also register additional file extensions/media types with:
|
# We can also register additional file extensions/media types with:
|
||||||
spring.mvc.content-negotiation.media-types.markdown=text/markdown
|
spring.mvc.contentnegotiation.media-types.markdown=text/markdown
|
||||||
----
|
----
|
||||||
|
|
||||||
If you understand the caveats and would still like your application to use
|
If you understand the caveats and would still like your application to use
|
||||||
|
@ -2090,13 +2090,13 @@ suffix pattern matching, the following configuration is required:
|
||||||
|
|
||||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||||
----
|
----
|
||||||
spring.mvc.content-negotiation.favor-path-extension=true
|
spring.mvc.contentnegotiation.favor-path-extension=true
|
||||||
|
|
||||||
# You can also restrict that feature to known extensions only
|
# You can also restrict that feature to known extensions only
|
||||||
# spring.mvc.path-match.use-registered-suffix-pattern=true
|
# spring.mvc.pathmatch.use-registered-suffix-pattern=true
|
||||||
|
|
||||||
# We can also register additional file extensions/media types with:
|
# We can also register additional file extensions/media types with:
|
||||||
# spring.mvc.content-negotiation.media-types.adoc=text/asciidoc
|
# spring.mvc.contentnegotiation.media-types.adoc=text/asciidoc
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue