我正在尝试使用 Spring MVC、Java 和 MySql 在我的 web 应用程序中实现完整的日历插件。当我尝试在 jsp 中使用“input type = date”添加日期时,出现此错误:
Field error in object 'event' on field 'endDate': rejected value [2018-03-13];
codes [typeMismatch.event.endDate,typeMismatch.endDate,typeMismatch.java.util.Date,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [event.endDate,endDate]; arguments [];
default message [endDate]]; default message [Failed to convert property value of type 'java.lang.String'
to required type 'java.util.Date' for property 'endDate'; nested exception is org.springframework.core.convert.ConversionFailedException:
Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat
java.util.Date for value '2018-03-13';
nested exception is java.lang.IllegalArgumentException: Unable to parse '2018-03-13']
Run Code Online (Sandbox Code Playgroud)
在我的控制器类中,我使用 SimpleDateFormat 来格式化我的日期: …