Field error in object 'books' on field 'bookId': rejected value [null]; codes [typeMismatch.books.bo

错误信息

01-May-2020 20:43:35.866 WARNING [http-nio-555-exec-1] org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.logException Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘books’ on field ‘bookId’: rejected value [null]; codes [typeMismatch.books.bookId,typeMismatch.bookId,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [books.bookId,bookId]; arguments []; default message [bookId]]; default message [Failed to convert value of type ‘null’ to required type ‘int’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [null] to type [int] for value ‘null’; nested exception is java.lang.IllegalArgumentException: A null value cannot be assigned to a primitive type]]

解决方法
底层的books的参数重写为bookID
PS: 但是当我重写回bookId的时候又没有问题了,怀疑是idea有bug

在这里插入图片描述
下面是Books类的代码,一开始bookId报错,重写成bookID后不报错了,但是再次重写成bookId不报错.

package com.psj.pojo;

public class Books {
   
    private int bookId;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值