Optional int parameter 'topicId' is present but cannot be translated into a null value due to being

来源:互联网 发布:pymongo 查询数据 编辑:程序博客网 时间:2024/05/21 09:31

项目运行成功,但是点击什么栏目或者栏目中名称带#出现500错误,后台报错代码是:

 Optional int parameter 'topicId' is present but cannot be translated into a null value due to being 

declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive 

type.

这段代码的主要意思是:

你定义的字段,我这里就是topicId这个字段定义成了int类型,但是在这个参数定义不是非必须的(也就是你的某个方法定义了这个参数,但是这个参数是非必须的,系统会自动给这个字段赋值为null值,但是int类型不能接收null值)

解决方法是:将int类型改成Integer封装类型.


注意:到这里我想你的上面报错信息应该就得以解决了,但是如果接下来你出现了NullpointException

出现这种情况的原因是你在该方法里面又调用了一个方法,并且被你调用的这个方法里面用到了你的这个字段参数,此时的解决方法就是显而易见了,把参数类型转成相应类型就OK了。

阅读全文
1 0