WebFlux ServerHttpRequest RequestBody 读取

MockServerHttpRequest request = MockServerHttpRequest.post("/test").body("test");
        DecoderHttpMessageReader httpMessageReader = new DecoderHttpMessageReader(new ByteArrayDecoder());
        ResolvableType resolvableType = ResolvableType.forClass(byte[].class);
        Mono mono = httpMessageReader.readMono(resolvableType, request, Collections.emptyMap());
        String body = mono.map(bytes -> new String(bytes)).block();

 

你可能感兴趣的:(java,微服务)