Error Description:
[Java] view plaincopy
@RequestMapping (value = "/index")
PublicString Index (@RequestParam(value ="Action", required =false)
String action, @RequestParam(value = "Notincludetypeid", required = false )
int Notincludetypeid) {
// .... Omit Code
}
When the optional parameter "Notincludetypeid" is empty, the system appears with the following error:
[Plain] view plaincopy
-
optional int parameter ' Notincludetypeid ' 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.
Cause of Error:
Spring defaults to NULL when the optional parameter "Notincludetypeid" does not exist, but the assignment fails because Notincludetypeid is already set to the base type int!
Workaround:
"Consider declaring it as Object wrapper for the corresponding primitive type." It is recommended that you use the wrapper type instead of the base type, such as "Integer" instead of "int"
Springmvc @RequestParam