diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index bfa1adf0296..ba198d3a37e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -122,6 +122,7 @@ public class WebMvcAutoConfiguration { @Bean @ConditionalOnMissingBean(HttpPutFormContentFilter.class) + @ConditionalOnProperty(prefix = "spring.mvc.formcontent.putfilter", name = "enabled", matchIfMissing = true) public OrderedHttpPutFormContentFilter httpPutFormContentFilter() { return new OrderedHttpPutFormContentFilter(); } diff --git a/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index f5034020e3d..4fefa5a20c4 100644 --- a/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -148,6 +148,12 @@ "description": "Enable resolution of favicon.ico.", "defaultValue": true }, + { + "name": "spring.mvc.formcontent.putfilter.enabled", + "type": "java.lang.Boolean", + "description": "Enable Spring's HttpPutFormContentFilter.", + "defaultValue": true + }, { "name": "spring.rabbitmq.dynamic", "type": "java.lang.Boolean", diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java index acd2d82d055..8b40cb7acb8 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java @@ -476,6 +476,13 @@ public class WebMvcAutoConfigurationTests { is(equalTo(1))); } + @Test + public void httpPutFormContentFilterCanBeDisabled() throws Exception { + load((Class) null, "spring.mvc.formcontent.putfilter.enabled=false"); + assertThat(this.context.getBeansOfType(HttpPutFormContentFilter.class).size(), + is(equalTo(0))); + } + @Test public void customConfigurableWebBindingInitializer() { load(CustomConfigurableWebBindingInitializer.class); diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index d10ea5eb7cd..7b9aff6c0e4 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -307,6 +307,7 @@ content into your application; rather pick only the properties that you need. spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method. spring.mvc.dispatch-options-request=false # Dispatch OPTIONS requests to the FrameworkServlet doService method. spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico. + spring.mvc.formcontent.putfilter.enabled=true # Enable Spring's HttpPutFormContentFilter. spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios. spring.mvc.locale= # Locale to use. spring.mvc.media-types.*= # Maps file extensions to media types for content negotiation.