IllegalStateException within method with Response paramether

前端 未结 1 1841
遥遥无期
遥遥无期 2020-12-17 14:54

I wrote a simple class to test response reading entity method (if it works as I expect). But it didn\'t worked well.

When I launch my class I get following error at

相关标签:
1条回答
  • 2020-12-17 15:28

    There are two types of Responses, inbound and outbound, though they still use the same interface. Outbound is when you are sending a response from the server-side

    Response response = Response.ok(entity).build();
    

    Inbound is when you are receiving the response on the client-side.

    Response response = webTarget.request().get();
    

    The readEntity() method is disabled on the server-side outbound response because you don't need it. It's only used when you need to de-serialize the response from the response stream. But there is none when it's outbound.

    If you want the entity on the outbound response, just use Response#getEntity()

    0 讨论(0)
提交回复
热议问题