zhangkaitao opened SPR-10592 and commented

@RequestParam(value="username", required=false) also report Required Long parameter 'userId' is not present

because of org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver的resolveArgument:

if (emptyArgValue && (arg == null)) {
handleMissingValue(namedValueInfo.name, parameter);
}


Affects: 3.2.3

Reference URL: http://jinnianshilongnian.iteye.com/blog/1878631

Issue Links: - #15207 Revert change for SPR-10402 that allowed treating empty values as missing values ("duplicates")

0 votes, 5 watchers

Comment From: spring-projects-issues

Simon Wong commented

I would like to add some comment for those readers who are not Chinese.

For web data binding, if the request parameters is bind to primitive type directly and @RequestParam is missing, which will throw exception "Required parameter xxxx is not present" as of Spring v3.2.3

Prior to v3.2.3, if @RequestParam is missing, it implicitly implies that the parameter is optional and would be default to empty string (or null).

According to the blog, AbstractNamedValueMethodArgumentResolver's resolveArgument() method with the following snippet be added which causes the problem.

if (emptyArgValue && (arg == null)) {
handleMissingValue(namedValueInfo.name, parameter);
}

Comment From: spring-projects-issues

Rossen Stoyanchev commented

This is fixed with #15207 and will be in 3.2.4 and 4.0.M2

Comment From: shashipratapsingh

Spring spring 3.2.3 @RequestParam(value=

is it fine or not

Comment From: bclozel

@shashipratapsingh please ask questions on StackOverflow. A minimal example is also required there if you want to get some help.