users@jersey.java.net

[Jersey] Re: how can I get json and xml result

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 14 Jun 2013 17:13:07 +0200

To clarify - the "qs" parameter acts only as a hint in case the client does not specify Accept header or specifies multiple values with same "q" value. In such case the qs parameter will be used to take the server preference into consideration. Of course, if client specifies his preference via Accept header, these client preferences are satisfied first.

Marek

On Jun 14, 2013, at 5:10 PM, Marek Potociar <marek.potociar_at_oracle.com> wrote:

> With JAX-RS/Jersey 2.0 you can also set the server-side content preference:
> https://jersey.java.net/nonav/documentation/2.0/jaxrs-resources.html#d0e1388
>
> Marek
>
> On Jun 14, 2013, at 1:20 PM, Andrzej Le¶kiewicz <andrzej.leskiewicz_at_gmail.com> wrote:
>
>> You should use the Accept header in Your request.
>>
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
>>
>>
>>
>> 2013/6/14 <everhow_at_163.com>
>> I can defined method with @Produces annotations, but how can I get
>> differenent result, eg, json and xml.
>>
>> @GET
>> @Path("/registerUser")
>> @Produces({ MediaType.APPLICATION_JSON,
>> MediaType.APPLICATION_XML })
>> public String registerUser(@QueryParam("deviceId") String
>> deviceId){...}
>>
>>
>>
>> --
>> Best regards
>> Andrzej Le¶kiewicz
>