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

FormHttpMessageConverter should support non-String form values [SPR-17645] #22174

spring-projects-issues opened this issue Jan 8, 2019 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jan 8, 2019

wsy opened SPR-17645 and commented

HttpEntity takes generic type T as request body.

When T is MultiValueMap<String, Object>, and the values of the map contains non-string values such as Integer, an invoke to RestTemplate (with Content-Type "application/x-www-form-urlencoded") will cause ClassCastException.

I've attached a demo project that can re-produce this bug. 

MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>();
body.add("Parameter1", "Value1"); // This is fine
body.add("Parameter2", 2147483647); // This value will trigger the bug after calling RestTemplate to send out this request.

I've already submitted a pull request. Pull Request #2078

Affects: 5.1.2


Referenced from: pull request #2078, and commits a82f049

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 8, 2019

Juergen Hoeller commented

I've merged your commit as part of an improvement where we're supporting MultiValueMap<String, Object> for form data as well now. I've also added a corresponding note to FormHttpMessageConverter's javadoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants