Obtaining raw request body in JAX-RS resource method

前端 未结 3 768
-上瘾入骨i
-上瘾入骨i 2020-12-15 22:21

How can I access the raw request body from a JAX-RS resource method, as java.io.InputStream or byte[]? I want the container to bypass any Mes

3条回答
  •  隐瞒了意图╮
    2020-12-15 23:04

    This works for me:

    @POST
    @Consumes(MediaType.WILDCARD)
    @Produces(MediaType.WILDCARD)
    public Response doSomething(@Context HttpServletRequest request, byte[] input) {
        log.debug("Content-Type: {}", request.getContentType());
        log.debug("Preferred output: {}", request.getHeader(HttpHeaders.ACCEPT));
    }
    

提交回复
热议问题