Allow override of data binding in ModelAttributeMethodArgumentResolver #24947
+10
−1
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.
Motivation
The Spring MVC
ModelAttributeMethodProcessor
includes many helpfulextension methods that allow developers to extend and enhance the data
binding capabilities of the class. Unfortunately, Spring WebFlux's
equivalent class, the
ModelAttributeMethodArgumentResolver
, does notinclude these same extension methods. I am leveraging these extension
methods, specifically the
bindRequestParameters
method, to providevaluable enhancements to my application. I would like to provide these
same enhancements to the WebFlux portion of my application and am
unable to do so at this time. I would like to update the WebFlux
ModelAttributeMethodArgumentResolver
to add thebindRequestParameters
method.
Modifications
I created a new method called
bindRequestParameters
and encapsulatedthe
WebExchangeDataBinder
bind call inside of it. This method ismarked as protected as it should only be used by children of this
class. This change mirrors the behavior in the equivalent Spring MVC
class (
ModelAttributeMethodProcessor
).Result
The WebFlux
ModelAttributeMethodArgumentResolver
can now acceptalternative data binding implementations mirroring the Web MVC
behavior.