赞
踩
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.http.converter.FormHttpMessageConverter.lambda$serializeForm$2(FormHttpMessageConverter.java:331)
- protected String serializeForm(MultiValueMap<String, String> formData, Charset charset) {
- StringBuilder builder = new StringBuilder();
- formData.forEach((name, values) ->
- values.forEach(value -> {
- try {
- if (builder.length() != 0) {
- builder.append('&');
- }
- builder.append(URLEncoder.encode(name, charset.name()));
- if (value != null) {
- builder.append('=');
- builder.append(URLEncoder.encode(value, charset.name()));
- }
- }
- catch (UnsupportedEncodingException ex) {
- throw new IllegalStateException(ex);
- }
- }));
-
- return builder.toString();
- }
可以看出MultiValueMap<String, String>的key和value都是String的
使用MultiValueMap传参的时候需要保证key和value都是String类型的
作者:猿份哥
原文链接:http://www.lskyf.com/view/36
版权声明:本文为博主原创文章,转载请附上博文链接!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。