泽西岛ContainerResponseFilter获取请求消息

时间:2019-04-30 14:37:47

标签: spring-boot jersey jersey-2.0

嗨,我使用jersey ContainerResponseFilter,在响应中我需要响应和请求消息,在MyApi执行并返回响应之后,mycontainerresponsefilter工作,但是当我尝试获取请求实体时,我得到了输入流关闭消息,我该如何读取输入容器responsefilter中的数据?

“实体输入流已经关闭。”

public Response MyApi(MyApiRequest request)
    {


        return Response.status(Response.Status.OK).entity(response).build();
    }


    >   public void filter(ContainerRequestContext containerRequestContext,
    > ContainerResponseContext containerResponseContext) throws IOException
    > { 
    >      ContainerRequest cr = (ContainerRequest)containerRequestContext;
    >                 cr.bufferEntity();
    >                 requestBody = (String)cr.readEntity(String.class); 

0 个答案:

没有答案