From 9a456924e45007156e1870b60da3591c9750ffb5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 7 Feb 2018 15:05:15 +0000 Subject: [PATCH] Remove - from path-match and content-negotiation properties Closes gh-11913 --- .../web/servlet/WebMvcAutoConfiguration.java | 20 +++++++++---------- .../web/servlet/WebMvcProperties.java | 16 +++++++-------- ...itional-spring-configuration-metadata.json | 2 +- .../servlet/WebMvcAutoConfigurationTests.java | 12 +++++------ .../appendix-application-properties.adoc | 12 +++++------ .../main/asciidoc/spring-boot-features.adoc | 12 +++++------ 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index 5c14825f25a..82a9e18d853 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -218,21 +218,21 @@ public class WebMvcAutoConfiguration { @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch( - this.mvcProperties.getPathMatch().isUseSuffixPattern()); + this.mvcProperties.getPathmatch().isUseSuffixPattern()); configurer.setUseRegisteredSuffixPatternMatch( - this.mvcProperties.getPathMatch().isUseRegisteredSuffixPattern()); + this.mvcProperties.getPathmatch().isUseRegisteredSuffixPattern()); } @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { - WebMvcProperties.ContentNegotiation contentNegotiation = this.mvcProperties - .getContentNegotiation(); - configurer.favorPathExtension(contentNegotiation.isFavorPathExtension()); - configurer.favorParameter(contentNegotiation.isFavorParameter()); - if (contentNegotiation.getParameterName() != null) { - configurer.parameterName(contentNegotiation.getParameterName()); - } - Map mediaTypes = this.mvcProperties.getContentNegotiation() + WebMvcProperties.Contentnegotiation contentnegotiation = this.mvcProperties + .getContentnegotiation(); + configurer.favorPathExtension(contentnegotiation.isFavorPathExtension()); + configurer.favorParameter(contentnegotiation.isFavorParameter()); + if (contentnegotiation.getParameterName() != null) { + configurer.parameterName(contentnegotiation.getParameterName()); + } + Map mediaTypes = this.mvcProperties.getContentnegotiation() .getMediaTypes(); for (Entry mediaType : mediaTypes.entrySet()) { configurer.mediaType(mediaType.getKey(), mediaType.getValue()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java index aa9a0429fa7..d43b602561b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java @@ -98,9 +98,9 @@ public class WebMvcProperties { 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() { return this.messageCodesResolverFormat; @@ -196,12 +196,12 @@ public class WebMvcProperties { return this.view; } - public ContentNegotiation getContentNegotiation() { - return this.contentNegotiation; + public Contentnegotiation getContentnegotiation() { + return this.contentnegotiation; } - public PathMatch getPathMatch() { - return this.pathMatch; + public Pathmatch getPathmatch() { + return this.pathmatch; } 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 @@ -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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 28e91bec224..34cd2b492a2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -414,7 +414,7 @@ "type" : "java.util.Map", "description" : "Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.", "deprecation" : { - "replacement" : "spring.mvc.content-negotiation.media-types", + "replacement" : "spring.mvc.contentnegotiation.media-types", "level" : "error" } }, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index f8e609d9380..d9bfb0c3f26 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -473,8 +473,8 @@ public class WebMvcAutoConfigurationTests { public void customMediaTypes() { this.contextRunner .withPropertyValues( - "spring.mvc.content-negotiation.media-types.yaml:text/yaml", - "spring.mvc.content-negotiation.favor-path-extension:true") + "spring.mvc.contentnegotiation.media-types.yaml:text/yaml", + "spring.mvc.contentnegotiation.favor-path-extension:true") .run((context) -> { RequestMappingHandlerAdapter adapter = context .getBean(RequestMappingHandlerAdapter.class); @@ -755,8 +755,8 @@ public class WebMvcAutoConfigurationTests { @Test public void useSuffixPatternMatch() { this.contextRunner - .withPropertyValues("spring.mvc.path-match.use-suffix-pattern:true", - "spring.mvc.path-match.use-registered-suffix-pattern:true") + .withPropertyValues("spring.mvc.pathmatch.use-suffix-pattern:true", + "spring.mvc.pathmatch.use-registered-suffix-pattern:true") .run((context) -> { RequestMappingHandlerMapping handlerMapping = context .getBean(RequestMappingHandlerMapping.class); @@ -782,7 +782,7 @@ public class WebMvcAutoConfigurationTests { public void pathExtensionContentNegotiation() { this.contextRunner .withPropertyValues( - "spring.mvc.content-negotiation.favor-path-extension:true") + "spring.mvc.contentnegotiation.favor-path-extension:true") .run((context) -> { RequestMappingHandlerMapping handlerMapping = context .getBean(RequestMappingHandlerMapping.class); @@ -797,7 +797,7 @@ public class WebMvcAutoConfigurationTests { @Test public void queryParameterContentNegotiation() { this.contextRunner - .withPropertyValues("spring.mvc.content-negotiation.favor-parameter:true") + .withPropertyValues("spring.mvc.contentnegotiation.favor-parameter:true") .run((context) -> { RequestMappingHandlerMapping handlerMapping = context .getBean(RequestMappingHandlerMapping.class); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index f089118908c..92d70a1a556 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -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.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.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.content-negotiation.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.favor-parameter=false # Whether a request parameter ("format" by default) 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.contentnegotiation.media-types.*= # Maps file extensions to media types for content negotiation. + 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.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. @@ -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.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.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.path-match.use-suffix-pattern=false # Whether to use suffix pattern match (".*") when matching patterns to requests. + 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.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.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. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 6ce1cac6a49..96ca37e6c8b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -2076,13 +2076,13 @@ will be mapped to `@GetMapping("/projects/spring-boot")`: [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: - # spring.mvc.content-negotiation.parameter-name=myparam + # spring.mvc.contentnegotiation.parameter-name=myparam # 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 @@ -2090,13 +2090,13 @@ suffix pattern matching, the following configuration is required: [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 - # 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: - # spring.mvc.content-negotiation.media-types.adoc=text/asciidoc + # spring.mvc.contentnegotiation.media-types.adoc=text/asciidoc ----