Fix ClassCastException in FormHttpMessageConverter
We should not cast MultiValueMap<String, ?> to MultiValueMap<String, String>
This commit is contained in:
parent
abc68ef8ea
commit
b94e8c4bef
|
|
@ -270,7 +270,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
throws IOException, HttpMessageNotWritableException {
|
throws IOException, HttpMessageNotWritableException {
|
||||||
|
|
||||||
if (!isMultipart(map, contentType)) {
|
if (!isMultipart(map, contentType)) {
|
||||||
writeForm((MultiValueMap<String, String>) map, contentType, outputMessage);
|
writeForm((MultiValueMap<String, Object>) map, contentType, outputMessage);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
writeMultipart((MultiValueMap<String, Object>) map, outputMessage);
|
writeMultipart((MultiValueMap<String, Object>) map, outputMessage);
|
||||||
|
|
@ -292,7 +292,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeForm(MultiValueMap<String, String> formData, @Nullable MediaType contentType,
|
private void writeForm(MultiValueMap<String, Object> formData, @Nullable MediaType contentType,
|
||||||
HttpOutputMessage outputMessage) throws IOException {
|
HttpOutputMessage outputMessage) throws IOException {
|
||||||
|
|
||||||
contentType = getMediaType(contentType);
|
contentType = getMediaType(contentType);
|
||||||
|
|
@ -325,7 +325,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String serializeForm(MultiValueMap<String, String> formData, Charset charset) {
|
protected String serializeForm(MultiValueMap<String, Object> formData, Charset charset) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
formData.forEach((name, values) ->
|
formData.forEach((name, values) ->
|
||||||
values.forEach(value -> {
|
values.forEach(value -> {
|
||||||
|
|
@ -336,7 +336,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
builder.append(URLEncoder.encode(name, charset.name()));
|
builder.append(URLEncoder.encode(name, charset.name()));
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
builder.append('=');
|
builder.append('=');
|
||||||
builder.append(URLEncoder.encode(value, charset.name()));
|
builder.append(URLEncoder.encode(String.valueOf(value), charset.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException ex) {
|
catch (UnsupportedEncodingException ex) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue