@@ -64,18 +64,13 @@ public WebExchangeDataBinder(Object target, String objectName) {
64
64
65
65
/**
66
66
* Bind the URL query parameters or form data of the body of the given request
67
- * to this binder's target. The request body is parsed if the content-type
68
- * is "application/x-www-form-urlencoded".
67
+ * to this binder's target. The request body is parsed if the Content-Type
68
+ * is {@code "application/x-www-form-urlencoded"} .
69
69
* @param exchange the current exchange.
70
- * @return a {@code Mono<Void>} to indicate the result
70
+ * @return a {@code Mono<Void>} when binding is complete
71
71
*/
72
72
public Mono <Void > bind (ServerWebExchange exchange ) {
73
- ServerHttpRequest request = exchange .getRequest ();
74
- Mono <MultiValueMap <String , String >> queryParams = Mono .just (request .getQueryParams ());
75
- Mono <MultiValueMap <String , String >> formParams =
76
- exchange .getFormData ().defaultIfEmpty (new LinkedMultiValueMap <>());
77
-
78
- return Mono .zip (this ::mergeParams , queryParams , formParams )
73
+ return exchange .getRequestParams ()
79
74
.map (this ::getParamsToBind )
80
75
.doOnNext (values -> values .putAll (getMultipartFiles (exchange )))
81
76
.doOnNext (values -> values .putAll (getExtraValuesToBind (exchange )))
@@ -85,15 +80,8 @@ public Mono<Void> bind(ServerWebExchange exchange) {
85
80
});
86
81
}
87
82
88
- @ SuppressWarnings ("unchecked" )
89
- private MultiValueMap <String , String > mergeParams (Object [] paramMaps ) {
90
- MultiValueMap <String , String > result = new LinkedMultiValueMap <>();
91
- Arrays .stream (paramMaps ).forEach (map -> result .putAll ((MultiValueMap <String , String >) map ));
92
- return result ;
93
- }
94
-
95
83
private Map <String , Object > getParamsToBind (MultiValueMap <String , String > params ) {
96
- Map <String , Object > valuesToBind = new TreeMap <>();
84
+ Map <String , Object > result = new TreeMap <>();
97
85
for (Map .Entry <String , List <String >> entry : params .entrySet ()) {
98
86
String name = entry .getKey ();
99
87
List <String > values = entry .getValue ();
@@ -102,14 +90,14 @@ private Map<String, Object> getParamsToBind(MultiValueMap<String, String> params
102
90
}
103
91
else {
104
92
if (values .size () > 1 ) {
105
- valuesToBind .put (name , values );
93
+ result .put (name , values );
106
94
}
107
95
else {
108
- valuesToBind .put (name , values .get (0 ));
96
+ result .put (name , values .get (0 ));
109
97
}
110
98
}
111
99
}
112
- return valuesToBind ;
100
+ return result ;
113
101
}
114
102
115
103
/**
0 commit comments