Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring 3.2.3 @RequestParam(value="username", required=false) bug [SPR-10592] #15221

Closed
spring-issuemaster opened this issue May 27, 2013 · 2 comments
Assignees

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented May 27, 2013

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

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 27, 2013

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);
}

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 20, 2013

Rossen Stoyanchev commented

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.