users@jersey.java.net

[Jersey] Re: is not recognized as valid Java method annotated with @HttpMethod.

From: Brad <brad.busch_at_gmail.com>
Date: Tue, 3 May 2011 16:30:16 +0000 (UTC)

Paul Sandoz <Paul.Sandoz@...> writes
>
> Hi Spencer,
>
> The problem is with the default values for the parameters of type int
> e.g.:
>
> > @FormParam("s") @DefaultValue("") int iStart
>
> Change it to:
>
> @FormParam("s") @DefaultValue("0") int iStart
>
> as the default value in this case needs to be a String value that can
> be converted to an int.
>
> Did you see anything else in the logs to indicate that? i think we
> could improve the error reporting for this aspect.
>
> Paul.
>


I'm seeing the same issue with a Post request and simply putting a numeric value
in a String format isn't working for a primitive int type or the Integer class.
 See below:

@DefaultValue ("0") @FormParam("year") int year,
@DefaultValue ("0") @FormParam("code") Integer code

The annotation throws an http 400 - Bad Requst because it can't convert the "0"
to an Integer even though Integer i = new Integer("1") is perfectly acceptable.

Any thoughts on how to make this work other than changing the parameter type to
a String and later creating an Integer out of it?

Thanks,
Brad