java.lang.IllegalStateException: Optional int parameter 'sno' 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.
时间: 2024-02-29 11:53:36 浏览: 238
Java异常之—-Caused by: java.lang.IllegalStateException: Method has too many Body parameters
这个错误是因为在使用Optional作为方法参数时,参数类型是原始类型,而不是对象包装器类型。原始类型无法为null,而Optional可以包含null值,因此会抛出IllegalStateException异常。你需要将参数类型改为对象包装器类型,如Integer。这样,Optional参数就可以包含null值了。
阅读全文