java - 前台String类型的时间字符串是否异常传输到后台?
问题描述
我在前台根据时间进行查询操作,将时间字符串“2020-08-02 12:30:30”传给后台,后台控制台抛出这个错误:
提示信息:
default message [Failed to convert property value of type'java.lang.String' to required type'java.util.Date' for property'scanTime'; 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 '2020-08-02 12:30:30'; nested exception is java.lang.IllegalArgumentException : Invalid format: "2020-08-02 12:30:30" is malformed at "12:30:30"]
数据库中的该字段是日期类型。我用了"@DateTimeFormat(iso=DateTimeFormat.ISO.DATE)"
前台的注解。为什么会出现这个错误?
@DateTimeFormat(iso=DateTimeFormat.ISO.DATE)
private Date scanTime;
解决方案
推荐阅读
- android - 如何通过更改过滤器修改recyclerview中的数据?
- python - 在多个条件下比较熊猫数据框中的行时,“ValueError:索引数据必须是一维的”
- python - 我的用户定义函数 apply-->lambdas 不断产生“ValueError:一系列的真值不明确”
- kotlin - RxJava2 Flowable在不使用create的情况下发出多个网络调用的结果?
- syntax - MIT-Scheme SICP Exercise_1.11——对象#t 不适用
- django - Django CMS动态图像
- sql - SQL WHERE 子句根据数据库内容获取行
- java - 检测玩家何时离开弹丸然后移除实体
- ios - iOS确定CBCharacteristic的数据长度
- sql - 分组集中的列不应该是 NULL = SQL Server 错误,或者更有可能是,我不理解分组集吗?