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

这个错误是因为java获取页面数据的时候,id值可能为空,而int的默认值为0,若想能够接受NULL的值,将int换成integer即可解决。

 

遇到这个错误就是把参数int 改成Integer 

大家以后在springmvc接受参数的时候,尽量不要使用基本数据类型,当然你一定要使用的话,可以把defaultValue加上,这样就不会报这个错误了。

注意:就算你加上required=false, 一样也是不行的。

posted @ 2020-08-06 20:06  傲娇的白狐  阅读(5641)  评论(0)    收藏  举报