Field error in object 'xxx' on field 'XXX': rejected value [];

探讨了在SSM框架中前端搜索条件为空时导致的转换错误问题,提出将属性类型的int改为Integer来解决该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SSM中,前端搜索条件为空时,value为“”,传值时无法转换为int,会导致加载controller之前就报错,故应把属性值得类型改为Integer,即可接收到null


Field error in object 'xxx' on field 'XXX': rejected value [];

codes [typeMismatch.XXX.xxx,typeMismatch.xxx,typeMismatch.int,typeMismatch]; 

arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [XXX.xxx,xxx]; arguments []; 

default message [xxx]]; 

default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'xxx'; nested exception is java.lang.NumberFormatException:

For input string: ""]

rg.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public com.xymzsfxy.backend.returncode.Result com.xymzsfxy.backend.controller.admin.ProductController.update(com.xymzsfxy.backend.entity.Product) with 2 errors: [Field error in object ‘product’ on field ‘createdTime’: rejected value [2025-03-06T15:23:49.000Z]; codes [typeMismatch.product.createdTime,typeMismatch.createdTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [product.createdTime,createdTime]; arguments []; default message [createdTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createdTime’; Failed to convert from type [java.lang.String] to type [@javax.persistence.Column @com.fasterxml.jackson.annotation.JsonFormat java.util.Date] for value [2025-03-06T15:23:49.000Z]]] [Field error in object ‘product’ on field ‘updatedTime’: rejected value [2025-03-06T15:23:49.000Z]; codes [typeMismatch.product.updatedTime,typeMismatch.updatedTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [product.updatedTime,updatedTime]; arguments []; default message [updatedTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘updatedTime’; Failed to convert from type [java.lang.String] to type [@javax.persistence.Column @com.fasterxml.jackson.annotation.JsonFormat java.util.Date] for value [2025-03-06T15:23:49.000Z]]] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:177) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179)
03-08
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值