-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Add support for custom x-www-form-urlencoded payload field names mapping #3890
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
Comments
Changes would need to be made in core Spring to support this. I've raised SPR-13433 for them to consider it. Feel free to track that issue. Thanks for the suggestion. |
@Smedzlatko Rossen has some followup questions if you could comment on SPR-13433 |
@philwebb As for the Rossens' comment: yes, I should have clarified this in my simplified example. It should , of course, be: @FormAttribute("value_first")
private String value1; As for the requirement, I am not saying that this is a core functionality of Spring that I am desperately missing but imagine this scenario: You are processing a form-encoded payload from a third party service and you want to use POJO to map the values. You use camelCase in your whole project and now you are forced to use underscopes if the third party service does so (in the POJO) or write your own converter just for this purpose. When I encountered this problem, I immediately looked for some Spring functionality to tackle this and was suprised that there is none. Feel free to close this issue if you feel that I am being unreasonable but I expected more people having this issue as well. |
@Smedzlatko Could you make that comment on SPR-13433, please? I'd copy it over but I think it would be better if it's obviously from you. |
@wilkinsona I have created an account there and copied my reply. Thank you for you support! |
When processing an
HttpRequest
withx-www-form-urlencoded
content, we can use a controller with POJO matching the payload structure.Example payload:
value_first=value1&value_second=value2
POJO:
The problem is that the variable names must match the field names in the
HttpRequest
payload in order to be processed by the controller. There is not way of naming them differently, for example, if I do not want to use underscopes in Java variable and method names.What I would appreciate would be using something like this:
The text was updated successfully, but these errors were encountered: