Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hum, the link you are pointing says that it is true for <strong>REQUESTS</strong> only. So you can accept only text plain but are free to produce what ever you want.</p> <p><strong>EDIT</strong> Try registering a custom responsefilter with code similar to that (maybe you already did it?):</p> <pre><code>@Provider public class HeaderRewriteFilter implements ContainerResponseFilter { @Override public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { response.setResponse(Response .fromResponse(response.getResponse()).header(HttpHeaders.CONTENT_TYPE, "text/plain").build()); return response; } } </code></pre> <p>However check the result to ensure it is ok if the response already contains this header. Otherwise you can try to modify the current response, but I am not sure you can as it might be an immutable object. And by the way it looks less clean to me :)</p> <pre><code>List&lt;Object&gt; contentTypes = response.getHttpHeaders().get(HttpHeaders.CONTENT_TYPE); contentTypes.clear(); contentTypes.add("text/plain"); </code></pre> <p>Also for doing json&lt;>java databiding you can check Genson library <a href="http://code.google.com/p/genson/" rel="nofollow">http://code.google.com/p/genson/</a>, it integrates well with Jersey. Just drop the jar in the classpath and run!</p> <p><strong>EDIT 2</strong> OK then you must do it in the other way, use produces "text/plain" and define a json bodywriter for for that type. Downside is that you will be able to produce only json. With Genson you could do it that way:</p> <pre><code>@Provider @Produces({ MediaType.TEXT_PLAIN }) public class PlainTextJsonConverter extends GensonJsonConverter { public GensonJsonConverter() { super(); } public GensonJsonConverter(@javax.ws.rs.core.Context Providers providers) { super(providers); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload