报错内容:
java.lang.IllegalStateException: Optional long parameter ‘studentId’ 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.
翻译:
java.lang.IllegalStateException:存在可选的长参数“studentId”,但由于被声明为基元类型,因此无法转换为null值。考虑将其声明为相应基元类型的对象包装器。
意思是说studentId
这个参数有可能为null
但是因为它的类型是java基本数据类型中的long
, 无法赋值为null
解决方法:
将基本数据类型long
替换为包装类Long
, 就可以赋值为null
了。