From 5e02a6dda37ba6ff3b2025a1b2a6200c49cdcdaf Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 2 Dec 2013 12:25:03 -0800 Subject: [PATCH] Fix casing in spring mvc namespace attributes Update "enableMatrixVariables" and "ignoreDefaultModelOnRedirect" to use the more conventional XML form "enable-matrix-variables" and "ignore-default-model-on-redirect". Both forms are now supported by `AnnotationDrivenBeanDefinitionParser`, with newer names being defined in the 4.0 XSD and the older names remaining in the 3.2 XSD. Issue: SPR-11136 --- .../AnnotationDrivenBeanDefinitionParser.java | 10 ++++++---- .../web/servlet/config/spring-mvc-4.0.xsd | 12 ++++++------ .../web/servlet/config/MvcNamespaceTests.java | 14 +++++++++++++- .../config/mvc-config-argument-resolvers.xml | 6 +++--- .../servlet/config/mvc-config-async-support.xml | 2 +- .../servlet/config/mvc-config-bean-decoration.xml | 4 ++-- .../mvc-config-content-negotiation-manager.xml | 4 ++-- .../mvc-config-custom-conversion-service.xml | 6 +++--- .../config/mvc-config-custom-validator-32.xml | 13 +++++++++++++ .../servlet/config/mvc-config-custom-validator.xml | 10 +++++----- .../mvc-config-default-servlet-optional-attrs.xml | 2 +- .../servlet/config/mvc-config-default-servlet.xml | 2 +- .../web/servlet/config/mvc-config-interceptors.xml | 6 +++--- .../config/mvc-config-message-codes-resolver.xml | 2 +- .../mvc-config-message-converters-defaults-off.xml | 4 ++-- .../config/mvc-config-message-converters.xml | 2 +- .../config/mvc-config-resources-optional-attrs.xml | 2 +- .../web/servlet/config/mvc-config-resources.xml | 2 +- .../config/mvc-config-return-value-handlers.xml | 2 +- .../config/mvc-config-view-controllers-minimal.xml | 4 ++-- .../servlet/config/mvc-config-view-controllers.xml | 6 +++--- .../web/servlet/config/mvc-config.xml | 2 +- 22 files changed, 72 insertions(+), 45 deletions(-) create mode 100644 spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator-32.xml diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index a686ac8bb6f..b60d4567bda 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -161,8 +161,9 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { handlerMappingDef.getPropertyValues().add("order", 0); handlerMappingDef.getPropertyValues().add("contentNegotiationManager", contentNegotiationManager); String methodMappingName = parserContext.getReaderContext().registerWithGeneratedName(handlerMappingDef); - if (element.hasAttribute("enableMatrixVariables")) { - Boolean enableMatrixVariables = Boolean.valueOf(element.getAttribute("enableMatrixVariables")); + if (element.hasAttribute("enable-matrix-variables") || element.hasAttribute("enableMatrixVariables")) { + Boolean enableMatrixVariables = Boolean.valueOf(element.getAttribute( + element.hasAttribute("enable-matrix-variables") ? "enable-matrix-variables" : "enableMatrixVariables")); handlerMappingDef.getPropertyValues().add("removeSemicolonContent", !enableMatrixVariables); } @@ -191,8 +192,9 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { handlerAdapterDef.getPropertyValues().add("contentNegotiationManager", contentNegotiationManager); handlerAdapterDef.getPropertyValues().add("webBindingInitializer", bindingDef); handlerAdapterDef.getPropertyValues().add("messageConverters", messageConverters); - if (element.hasAttribute("ignoreDefaultModelOnRedirect")) { - Boolean ignoreDefaultModel = Boolean.valueOf(element.getAttribute("ignoreDefaultModelOnRedirect")); + if (element.hasAttribute("ignore-default-model-on-redirect") || element.hasAttribute("ignoreDefaultModelOnRedirect")) { + Boolean ignoreDefaultModel = Boolean.valueOf(element.getAttribute( + element.hasAttribute("ignore-default-model-on-redirect") ? "ignore-default-model-on-redirect" : "ignoreDefaultModelOnRedirect")); handlerAdapterDef.getPropertyValues().add("ignoreDefaultModelOnRedirect", ignoreDefaultModel); } if (argumentResolvers != null) { diff --git a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.0.xsd b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.0.xsd index ae5ee0527be..7ebb96c72c4 100644 --- a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.0.xsd +++ b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.0.xsd @@ -80,7 +80,7 @@ - + - + - + - + + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - - + + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-async-support.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-async-support.xml index 07dad7e38e2..6f09d4a4f88 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-async-support.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-async-support.xml @@ -2,7 +2,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-bean-decoration.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-bean-decoration.xml index 2a4f5990038..8efc770f8d2 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-bean-decoration.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-bean-decoration.xml @@ -4,7 +4,7 @@ xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> @@ -12,7 +12,7 @@ - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-content-negotiation-manager.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-content-negotiation-manager.xml index 612999a52fb..76fa6539570 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-content-negotiation-manager.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-content-negotiation-manager.xml @@ -2,8 +2,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-conversion-service.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-conversion-service.xml index 32d827a8225..98eeacf4dac 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-conversion-service.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-conversion-service.xml @@ -3,10 +3,10 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - + - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator-32.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator-32.xml new file mode 100644 index 00000000000..05897f75538 --- /dev/null +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator-32.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml index 6efe9e15573..2148f42cee1 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml @@ -3,11 +3,11 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> + + - - - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet-optional-attrs.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet-optional-attrs.xml index 36a1cb2dc71..75bd0660411 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet-optional-attrs.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet-optional-attrs.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet.xml index 89f79e8d8d6..0682ac002bb 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-default-servlet.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-interceptors.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-interceptors.xml index 780d9c379e2..3b4c26f6c30 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-interceptors.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-interceptors.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> @@ -23,7 +23,7 @@ - - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-codes-resolver.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-codes-resolver.xml index 0eea3e204f7..e682bc63275 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-codes-resolver.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-codes-resolver.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters-defaults-off.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters-defaults-off.xml index 81bfcdfcfc4..cebb1f42580 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters-defaults-off.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters-defaults-off.xml @@ -2,8 +2,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters.xml index 258952baf44..0d151c81a8b 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources-optional-attrs.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources-optional-attrs.xml index c38026b0a5e..05bee9b008f 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources-optional-attrs.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources-optional-attrs.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources.xml index 1d3dff96048..82dd141b059 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-resources.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-return-value-handlers.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-return-value-handlers.xml index 0e095677e08..78e0d64e1f5 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-return-value-handlers.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-return-value-handlers.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers-minimal.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers-minimal.xml index db5627e0699..fdfe28ff68f 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers-minimal.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers-minimal.xml @@ -3,8 +3,8 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers.xml index 4188835f461..fe2f06d31ea 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config-view-controllers.xml @@ -3,12 +3,12 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> - + @@ -17,5 +17,5 @@ - + diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config.xml b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config.xml index 1b0b4c7212e..2711815969d 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config.xml +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/config/mvc-config.xml @@ -3,7 +3,7 @@ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">