- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug
Milestone
Description
Keith Donald opened SPR-7348 and commented
To reproduce:
- Define a JavaBean with a List property that uses a type conversion annotation e.g. @DateTimeFormat(iso=Iso.DATE) List<Date> dates;
- Attempt to bind element values e.g. dates[0]=2010-07-04&dates[1]=2011-07-04. Instead of succeeding, the following binding error will be returned:
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errors
Field error in object 'javaBean' on field 'dates[0]': rejected value [2010-07-04]; codes [typeMismatch.javaBean.dates[0],typeMismatch.javaBean.dates,typeMismatch.dates[0],typeMismatch.dates,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [javaBean.dates[0],dates[0]]; arguments []; default message [dates[0]]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'dates[0]'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "2010-07-04" from type 'java.lang.String' to type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "2010-07-04" from type 'java.lang.String' to type 'java.util.Date'; nested exception is java.lang.IllegalArgumentException]
Field error in object 'javaBean' on field 'dates[1]': rejected value [2011-07-04]; codes [typeMismatch.javaBean.dates[1],typeMismatch.javaBean.dates,typeMismatch.dates[1],typeMismatch.dates,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [javaBean.dates[1],dates[1]]; arguments []; default message [dates[1]]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'dates[1]'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "2011-07-04" from type 'java.lang.String' to type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "2011-07-04" from type 'java.lang.String' to type 'java.util.Date'; nested exception is java.lang.IllegalArgumentException]
	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:809)
	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:358)
	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:170)
	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
This can be conveniently reproduced by checking out:
https://src.springsource.org/svn/spring-samples/mvc-showcase/
... deploying the app, and clicking on the "JavaBean with String-to-propertyType conversion" link in the "Type Conversion" section of the home page.
I tested against 3.0.4 snapshot, 3.0.3, 3.0.2, and 3.0.1, and apparently this never worked.  Interestingly, binding a String request parameter to a annotated @Controller List<Date> method argument works fine.
Affects: 3.0.3
Issue Links:
- Add Formatter support to generic collections [SPR-6504] #11170 Add Formatter support to generic collections
Referenced from: commits 66abad2
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug