Skip to content

Commit b97e0bd

Browse files
committed
Allow HttpPutFormContentFilter to be disabled
Add `spring.mvc.formcontent.putfilter.enabled` property to allow the HttpPutFormContentFilter to be disabled. Fixes gh-6519
1 parent a2e4127 commit b97e0bd

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
122122

123123
@Bean
124124
@ConditionalOnMissingBean(HttpPutFormContentFilter.class)
125+
@ConditionalOnProperty(prefix = "spring.mvc.formcontent.putfilter", name = "enabled", matchIfMissing = true)
125126
public OrderedHttpPutFormContentFilter httpPutFormContentFilter() {
126127
return new OrderedHttpPutFormContentFilter();
127128
}

spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
"description": "Enable resolution of favicon.ico.",
149149
"defaultValue": true
150150
},
151+
{
152+
"name": "spring.mvc.formcontent.putfilter.enabled",
153+
"type": "java.lang.Boolean",
154+
"description": "Enable Spring's HttpPutFormContentFilter.",
155+
"defaultValue": true
156+
},
151157
{
152158
"name": "spring.rabbitmq.dynamic",
153159
"type": "java.lang.Boolean",

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ public void httpPutFormContentFilterCanBeOverridden() {
476476
is(equalTo(1)));
477477
}
478478

479+
@Test
480+
public void httpPutFormContentFilterCanBeDisabled() throws Exception {
481+
load((Class<?>) null, "spring.mvc.formcontent.putfilter.enabled=false");
482+
assertThat(this.context.getBeansOfType(HttpPutFormContentFilter.class).size(),
483+
is(equalTo(0)));
484+
}
485+
479486
@Test
480487
public void customConfigurableWebBindingInitializer() {
481488
load(CustomConfigurableWebBindingInitializer.class);

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ content into your application; rather pick only the properties that you need.
307307
spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method.
308308
spring.mvc.dispatch-options-request=false # Dispatch OPTIONS requests to the FrameworkServlet doService method.
309309
spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico.
310+
spring.mvc.formcontent.putfilter.enabled=true # Enable Spring's HttpPutFormContentFilter.
310311
spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios.
311312
spring.mvc.locale= # Locale to use.
312313
spring.mvc.media-types.*= # Maps file extensions to media types for content negotiation.

0 commit comments

Comments
 (0)