[Solved] Error reported: org.springframework.validation.BeanPropertyBindingResult

Error content: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object’price’ on field’endTime’: rejected value [2018-07-31]; codes [typeMismatch.price.endTime,typeMismatch.endTime,typeMismatch. java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [price.endTime,endTime]; arguments []; default message [endTime]]; default message [Failed to convert property value of type’java.lang.String’ to required type’java.util.Date’ for property’endTime’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@javax.persistence.Column java.util.Date] for value ‘2018-07-31’; nested exception is java.lang.IllegalArgumentException:Parse attempt failed for value [2018-07-31]]


When SpringMvc is configured, the accepted period is formatted as yyyy-MM-dd HH:mm:ss by default. And because the date plug-in used is in the format of year, month, and day. Therefore, there is a problem of Spring conversion Date conversion failure.

There is a problem here, I hope I know what’s going on in the future? During this period, I set breakpoints in the configuration, but only the breakpoints entered when the project was started, but did not enter the breakpoints when calling the interface later. There is a guess here. In Spring, the configuration is initialized only when the project is started, and then it does not enter the method of initializing the configuration when it is called.


The way to solve the problem: Since it is the process of mapping, Spring cannot be converted to Date, and it is related to the overall configuration. I don’t want to change the general configuration, so I use HttpServletRequest to get the parameters directly. There will be no problems. The accepted parameter is directly Spring, which needs to be converted to Date by itself

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *