From 44ef114981ac50769d58f731c27ce0291ac78ddf Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 20 Feb 2010 16:14:14 +0000 Subject: [PATCH] fixed @RequestParam(required=false) regression for @InitBinder methods (SPR-6878) --- .../annotation/ServletAnnotationControllerTests.java | 12 ++++++++---- .../annotation/support/HandlerMethodInvoker.java | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationControllerTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationControllerTests.java index ea00315a00..acc7c57180 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationControllerTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ServletAnnotationControllerTests.java @@ -1479,11 +1479,13 @@ public class ServletAnnotationControllerTests { } @InitBinder - public void initBinder(@RequestParam("param1") T p1, int param2) { + public void initBinder(@RequestParam("param1") String p1, @RequestParam(value="paramX", required=false) String px, int param2) { + assertNull(px); } @ModelAttribute - public void modelAttribute(@RequestParam("param1") T p1, int param2) { + public void modelAttribute(@RequestParam("param1") String p1, @RequestParam(value="paramX", required=false) String px, int param2) { + assertNull(px); } } @@ -1516,12 +1518,14 @@ public class ServletAnnotationControllerTests { @Override @InitBinder - public void initBinder(@RequestParam("param1") String p1, int param2) { + public void initBinder(@RequestParam("param1") String p1, @RequestParam(value="paramX", required=false) String px, int param2) { + assertNull(px); } @Override @ModelAttribute - public void modelAttribute(@RequestParam("param1") String p1, int param2) { + public void modelAttribute(@RequestParam("param1") String p1, @RequestParam(value="paramX", required=false) String px, int param2) { + assertNull(px); } } diff --git a/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java b/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java index 5c2ebf0714..c5649ce2c8 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java +++ b/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java @@ -358,7 +358,7 @@ public class HandlerMethodInvoker { RequestParam requestParam = (RequestParam) paramAnn; paramName = requestParam.value(); paramRequired = requestParam.required(); - paramDefaultValue = requestParam.defaultValue(); + paramDefaultValue = parseDefaultValueAttribute(requestParam.defaultValue()); break; } else if (ModelAttribute.class.isInstance(paramAnn)) { -- GitLab