java.lang.IllegalStateException: Optional int parameter 'id' is not present but cannot be translated

版权声明:本文为博主原创文章,允许转载不允许复制。 https://blog.csdn.net/qq_30938705/article/details/80626882

异常如下:

Caused by: java.lang.IllegalStateException: Optional int parameter 'id' is not 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.
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.checkValue(HandlerMethodInvoker.java:750)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:518)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:355)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
	... 38 common frames omitted

解决方法:

将controller层接收数据的int的类型改为将Integer

阅读更多

没有更多推荐了,返回首页