diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java index 4eb74556496..59623e9503d 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java @@ -64,18 +64,13 @@ public class WebExchangeDataBinder extends WebDataBinder { /** * Bind the URL query parameters or form data of the body of the given request - * to this binder's target. The request body is parsed if the content-type - * is "application/x-www-form-urlencoded". + * to this binder's target. The request body is parsed if the Content-Type + * is {@code "application/x-www-form-urlencoded"}. * @param exchange the current exchange. - * @return a {@code Mono} to indicate the result + * @return a {@code Mono} when binding is complete */ public Mono bind(ServerWebExchange exchange) { - ServerHttpRequest request = exchange.getRequest(); - Mono> queryParams = Mono.just(request.getQueryParams()); - Mono> formParams = - exchange.getFormData().defaultIfEmpty(new LinkedMultiValueMap<>()); - - return Mono.zip(this::mergeParams, queryParams, formParams) + return exchange.getRequestParams() .map(this::getParamsToBind) .doOnNext(values -> values.putAll(getMultipartFiles(exchange))) .doOnNext(values -> values.putAll(getExtraValuesToBind(exchange))) @@ -85,15 +80,8 @@ public class WebExchangeDataBinder extends WebDataBinder { }); } - @SuppressWarnings("unchecked") - private MultiValueMap mergeParams(Object[] paramMaps) { - MultiValueMap result = new LinkedMultiValueMap<>(); - Arrays.stream(paramMaps).forEach(map -> result.putAll((MultiValueMap) map)); - return result; - } - private Map getParamsToBind(MultiValueMap params) { - Map valuesToBind = new TreeMap<>(); + Map result = new TreeMap<>(); for (Map.Entry> entry : params.entrySet()) { String name = entry.getKey(); List values = entry.getValue(); @@ -102,14 +90,14 @@ public class WebExchangeDataBinder extends WebDataBinder { } else { if (values.size() > 1) { - valuesToBind.put(name, values); + result.put(name, values); } else { - valuesToBind.put(name, values.get(0)); + result.put(name, values.get(0)); } } } - return valuesToBind; + return result; } /**