Skip to content

Constructor based bean binding should support url path variables, not only request parameters #24107

@rob-valor

Description

@rob-valor

Currently (Spring 5.2) we can not use constructor based bean binding of path variables as we can with request parameters. This is somewhat an inconsistent way of binding url data. Bean property binding is supported for both types of parameters but therefor a mutable object is required.

In method constructAttribute (ModelAttributeMethodProcessor.java:277) the values for constructor parameters are only taken from webRequest.getParameterValues(paramName) so no path variables are taken into account here. It's only when that constructed attribute object is bind by bindRequestParameters(binder, webRequest) in method resolveArgument (ModelAttributeMethodProcessor.java:160) that the path variables (as well as the request parameters again) are eventually added for bean property binding in method ServletRequestDataBinder#bind.

I mentioned this problem in issue 22600 and was correctly advised to create a separate issue for this to avoid a mixed conversation.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions