Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer can be found in this post: <a href="http://jersey.576304.n2.nabble.com/extension-custom-negotiation-td3078866.html" rel="nofollow">http://jersey.576304.n2.nabble.com/extension-custom-negotiation-td3078866.html</a></p> <p>Essentially you configure a ResourceConfig <a href="https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html" rel="nofollow">https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html</a></p> <p>You need to extend an implementation of ResourceConfig [1] and override the media type mappings method.</p> <p>For example you can do the following:</p> <pre><code>package foo; public class MyResourceConfig extends PackagesResourceConfig { public PackagesResourceConfig(Map&lt;String, Object&gt; props) { super(props); } public Map&lt;String, MediaType&gt; getMediaTypeMappings() { Map&lt;String, MediaType&gt; m = new HashMap&lt;String, MediaType&gt; (); m.put("json", MediaType.APPLICATION_JSON_TYPE); m.put("xml", MediaType.APPLICATION_XML_TYPE); return m; } } </code></pre> <p>and you can register your "MyResourceConfig" as described here:</p> <p><a href="https://jersey.dev.java.net/documentation/1.1.0-ea/user-guide.html#d4e115" rel="nofollow">https://jersey.dev.java.net/documentation/1.1.0-ea/user-guide.html#d4e115</a></p> <p>In the above example your web.xml would need to container:</p> <pre><code>&lt;web-app&gt; &lt;servlet&gt; &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt; &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;javax.ws.rs.Application&lt;/param-name&gt; &lt;param-value&gt;foo.MyResourceConfig&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt; &lt;param-value&gt;org.foo.rest;org.bar.rest&lt;/param-value&gt; &lt;/init-param&gt; &lt;/servlet&gt; .... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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