From 037936c4004f7b31ee8e8fa9ed8797bcac2d5d5d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 26 Jul 2011 12:36:01 +0000 Subject: [PATCH] SPR-8561 Permit null values for simple controller method arguments types without annotations. git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4791 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../support/RequestParamMethodArgumentResolver.java | 2 +- .../support/RequestParamMethodArgumentResolverTests.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/org.springframework.web/src/main/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolver.java b/org.springframework.web/src/main/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolver.java index 24f3f90dd97..91b8640a4c0 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolver.java +++ b/org.springframework.web/src/main/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolver.java @@ -194,7 +194,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod private class RequestParamNamedValueInfo extends NamedValueInfo { private RequestParamNamedValueInfo() { - super("", true, ValueConstants.DEFAULT_NONE); + super("", false, ValueConstants.DEFAULT_NONE); } private RequestParamNamedValueInfo(RequestParam annotation) { diff --git a/org.springframework.web/src/test/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolverTests.java b/org.springframework.web/src/test/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolverTests.java index 10884503207..98f4e3c0d3d 100644 --- a/org.springframework.web/src/test/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolverTests.java +++ b/org.springframework.web/src/test/java/org/springframework/web/method/annotation/support/RequestParamMethodArgumentResolverTests.java @@ -16,6 +16,7 @@ package org.springframework.web.method.annotation.support; +import static org.junit.Assert.*; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -221,6 +222,14 @@ public class RequestParamMethodArgumentResolverTests { assertEquals("plainValue", result); } + // SPR-8561 + + @Test + public void resolveSimpleTypeParamToNull() throws Exception { + Object result = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, null); + assertNull(result); + } + public void params(@RequestParam(value = "name", defaultValue = "bar") String param1, @RequestParam("name") String[] param2, @RequestParam("name") Map param3,