官网并不提供form data
以下方式获取
@RequestMapping(path = "/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> post(ServerWebExchange exchange,
@RequestBody(required = false) String body) throws IOException {
HashMap<String, Object> ret = new HashMap<>();
ret.put("headers", getHeaders(exchange));
ret.put("data", body);
HashMap<String, Object> form = new HashMap<>();
ret.put("form", form);
return exchange.getFormData().flatMap(map -> {
for (Map.Entry<String, List<String>> entry: map.entrySet()) {
for (String value : entry.getValue()) {
form.put(entry.getKey(), value);
}
}
return Mono.just(ret);
});
}
标签:HashMap,form,exchange,WebFlux,ret,put,data
From: https://www.cnblogs.com/guanchaoguo/p/18146189