Optional int parameter 'xx' is present but cannot be translated into a null value
阿新 • • 發佈:2019-02-14
今天在controller中獲取post引數時,報瞭如下錯誤
{ "timestamp": "2018-09-07T07:25:51.524+0000", "status": 500, "error": "Internal Server Error", "message": "Optional int parameter 'id' 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.", "path": "/user/add" }
檢視報錯資訊
Optional int parameter 'id' is present but cannot be translated into a null value
意思是id不能轉換為空,後面也給出了修改的建議
Consider declaring it as object wrapper for the corresponding primitive type.
可以用包裝類來避免這個錯誤
在springmvc接受引數的時候,儘量不要使用基本資料型別