diff --git a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java index 9191f5ae..4affbee3 100644 --- a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java +++ b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java @@ -24,6 +24,7 @@ import java.io.Writer; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; @@ -48,6 +49,7 @@ import org.springframework.core.Ordered; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.lang.Nullable; +import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.util.UriComponentsBuilder; @@ -151,9 +153,15 @@ public class FormFilter implements Filter, Ordered { } writer.flush(); + MultiValueMap combineQueryParams = new LinkedMultiValueMap<>(); + for (Map.Entry entry : form.entrySet()) { + combineQueryParams.put(entry.getKey(), new ArrayList<>(Arrays.asList(entry.getValue()))); + } + combineQueryParams.addAll(queryParams); + ByteArrayServletInputStream servletInputStream = new ByteArrayServletInputStream( new ByteArrayInputStream(bos.toByteArray())); - return new FormContentRequestWrapper(request, queryParams) { + return new FormContentRequestWrapper(request, combineQueryParams) { @Override public ServletInputStream getInputStream() throws IOException { return servletInputStream;