Fix web parameters resolution when injected via constructor#25200
Closed
encircled wants to merge 1 commit into
Closed
Fix web parameters resolution when injected via constructor#25200encircled wants to merge 1 commit into
encircled wants to merge 1 commit into
Conversation
Contributor
Author
|
@sbrannen just a kind reminder. Lets review&merge or close it. This bug should be addressed somehow though. |
Member
|
Thanks for the reminder. Since this appears to be a bug, we'll see about getting it merged into |
Contributor
Author
|
Alright, I will rebase it on the latest master then |
4ec48de to
cadfe32
Compare
Member
Thanks for rebasing it on |
sbrannen
added a commit
that referenced
this pull request
May 8, 2021
Member
sbrannen
pushed a commit
to sbrannen/spring-framework
that referenced
this pull request
May 10, 2021
…tors Prior to this commit, when Web MVC attempted to resolve a constructor argument for a data class constructor with @ModelAttribute binding, ModelAttributeMethodProcessor failed to unwrap the array returned by WebRequest.getParameter(String). According to the Javadoc for WebRequest.getParameter(String), "a single-value parameter will be exposed as an array with a single element." This commit fixes this issue by extracting the single value from such an array and using that as the constructor argument (potentially converted by the WebDataBinder). Closes spring-projectsgh-25200
sbrannen
added a commit
that referenced
this pull request
May 10, 2021
lxbzmy
pushed a commit
to lxbzmy/spring-framework
that referenced
this pull request
Mar 26, 2022
…tors Prior to this commit, when Web MVC attempted to resolve a constructor argument for a data class constructor with @ModelAttribute binding, ModelAttributeMethodProcessor failed to unwrap the array returned by WebRequest.getParameter(String). According to the Javadoc for WebRequest.getParameter(String), "a single-value parameter will be exposed as an array with a single element." This commit fixes this issue by extracting the single value from such an array and using that as the constructor argument (potentially converted by the WebDataBinder). Closes spring-projectsgh-25200
lxbzmy
pushed a commit
to lxbzmy/spring-framework
that referenced
this pull request
Mar 26, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the problem described in #25182
Comma-separated multi value parameters are wrongly injected if constructor injection is used. Only spring-web is affected, webflux works correctly.
For example
...?listOfStrings=1,2becomesList<String> listOfStrings = ["1,2"], instead of expectedList<String> listOfStrings = ["1", "2"]. The reason is thatWebRequest#getParameterValuesexposes single item params as an array which breaks conversion service later on.