Tag Archives: org.springframework.validation.BeanPropertyBindingResult

[Solved] Error: 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 configuring spring MVC, the accepted period is formatted as yyyy MM DD HH: mm: ss by default. Because the date plug-in used is in the format of year, month and day. Therefore, the conversion of spring date failed

 

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

Solution: since spring cannot be converted to date in the mapping process, it is related to the overall configuration. I didn’t want to change the overall configuration, so I used HttpServletRequest to get the parameters directly. There will be no problem. The accepted parameter is directly spring, which needs to be converted to date