On Jun 22, 2009, at 10:49 PM, Saavedra, Gisella wrote:
> Re: INFO: Initiating Jersey application, version 'Jersey: 1.1.0-ea
>
>
> I have a REST service with a parameter of type List<String>.
>
> @POST
> @Produces("application/octet-stream")
> @Consumes("application/x-www-form-urlencoded")
> public Response getLogBundle(@FormParam("fromMillis") Long
> inFromMillis,
> @FormParam("toMillis") Long
> inToMillis,
> @FormParam("fileList") List<String>
> inFileList) {
> …
> }
>
> At the client side, when I am building the FormData, I call
> formData.add("fileList", inNamedLogs);
> where inNamedLogs is a List<String>
>
Are are using the Form.add method that does the following:
public final void add(String key, Object value) {
List<String> l = getList(key);
if (value != null)
l.add(value.toString());
else
l.add("");
}
Namely it converts the value to a String by called value.toString().
So the information is getting converted on the client side. The "add"
methods will only add a single value.
Try doing:
formData.put("fileList", inNamedLogs);
or add each item in the list individually.
Paul.
The problem is the above, you are adding a list and it is getting
converted to a String using the toS
> See the value of my formDataàfileList argument (you can see the
> source and how it has been saved). There are TWO [[ surrounding the
> value.
>
> <image002.png>
>
> On the server side, getLogBundle() (code above), when I see the
> contents of fileList, I see each element having ONE [ surrounding
> the value.
> So, when I do inFileList.get(0), I get “[C:\\N4\\sandbox…]” instead
> of “C:\\N4\\sandbox…”
>
> Is this a bug? The documentation for the FormParam tag says that
> List<T> is supported; in this case T is String. I believe steps 1 to
> 4 of the JavaDoc are satisified.
>
> Please advise. Thanks.
>
> Gisella Saavedra
> Sr. Software Engineer
> gsaavedra_at_zebra.com
> <image001.gif>
> 1000 Broadway, Suite 150, Oakland, CA 94607 | T+1 510 267 5123 T
> Main+1 510 267 5000 F+1 510 267 5100 | http://www.zebra.com/zes
>
>
>