users@jersey.java.net

Re: [Jersey] primitive types - best response format ??

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 04 May 2009 10:37:46 +0200

On May 1, 2009, at 6:01 PM, Tatu Saloranta wrote:

> 2009/5/1 Felipe Gaścho <fgaucho_at_gmail.com>:
>> when I want to return Java primitive types, what is the best media
>> type ? or other response type ?
>>
>> like:
>>
>> @GET
>> @Produces( { MediaType.TEXT_PLAIN })
>> @Path("/count")
>> public String count() {
>> return Long.toString(userFacade.count());
>> }
>
> Text/plain seems good... but you might as well return plain old int or
> long from the method itself? Or are those not automatically converted
> yet?
>

No. JAX-RS does not define support for such non-String-based primitive
types. It is an open question to what exactly should be the string
format of such primitive types.

Paul.