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:
- org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [XXX.xml]‘;
- [Solved] springmvc:Error creating bean with name ‘org.springframework.cache.interceptor.CacheInterceptor
- [Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘globalTransa
- [Solved] SpringBoot Project Start Error: No bean named ‘org.springframework.context.xxxxx.importRegistry‘ available
- How to Solve Springmvc Error: org.springframework.web.servlet.DispatcherServlet
- [Solved] org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column ‘Sage‘ fr
- Start error in maven web project java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- [Solved] Redis Cache Error: org.springframework.data.redis.serializer.SerializationException: Could not read JSON..
- [Solved] swagger3 Error: org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] Bat starts springboot project error: ERROR org.springframework.boot.SpringApplication -Application run failed
- SpringBoot Access Clickhouse Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdbcConverter’ defined in class path resource [***.class]
- Gateway Error: Cannot resolve org.springframework.cloud:spring-cloud-starter-gateway:unknown
- [Solved] liquibase.exception.ValidationFailedException: Validation Failed
- [Solved] Openwrt Pptpd Start Error: validation filed
- stm32cubeAI “validation on target “ ERROR [How to Solve]
- [Rails 6] How to deal with ActiveRecord :: RecordInvalid: Validation failed:
- WPF path = (validation. Errors) [0]. Errorcontent reports a binding error
- [Exception] javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed
- package golang.org/x/net/XXX: unrecognized import path “golang.org/x/net/xxx“…