在java中报错如下
2022-10-07 10:28:32.825 ERROR 13744 --- [io-8080-exec-10] c.e.C.handler.GlobalExceptionHandler : HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.Integer'. Check configuration for 'activityMoney'
2022-10-07 10:28:32.826 WARN 13744 --- [io-8080-exec-10] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.Integer'. Check configuration for 'activityMoney']
个人刚开始还以为activityMoney这个属性设置的为空,但是没有从前端传进来。可是看了一圈发现activityMoney前后端都已经正确传送,最后才发现是activityMoney的属性判断写错了。
我的错误写法如下:
而activityMoney是int类型,不能用NotBlank
进行判空,NotBlank
是对字符串进行判断的。对int类型的判断应该用NotNull
,修改如下:
现在传值就没有报错啦!