Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I map semicolon-separated PathParams in Jersey?
    text
    copied!<p>Is there a way to use this parameter style:</p> <blockquote> <p>/products/123;456;789</p> </blockquote> <p>in JAX-RS with Jersey? If I use PathParam, only the first parameter in the list is returned. I tried to escape the semicolon but then Jersey returns only "123;456;789" as the value of the first parameter list entry</p> <p>I declared the GET method as</p> <pre><code>public List&lt;Product&gt; getClichedMessage(@PathParam("ids") List&lt;String&gt; idList) </code></pre> <p>Update: I am referring to the <a href="http://jersey.java.net/nonav/documentation/1.1.5/user-guide.html#d4e226" rel="noreferrer">Jersey user guide</a> for Jersey 1.1.5:</p> <blockquote> <p>In general the Java type of the method parameter may (...) 4) be List, Set or SortedSet, where T satisfies 2 or 3 above. The resulting collection is read-only. (...) Sometimes parameters may contain more than one value for the same name. If this is the case then types in 4) may be used to obtain all values.</p> </blockquote> <p>Update: here is my test code:</p> <pre><code>package de.betabeans.resources; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @Path("/test") public class TestResource { @GET @Path("/{ids}") @Produces({"text/plain"}) public String getClichedMessage(@PathParam("ids") List&lt;String&gt; idList) { return "size=" + idList.size(); } } </code></pre> <p>Test URL with semicolon escaped: <a href="http://localhost:8080/resources/test/1%3B2%3B3" rel="noreferrer">http://localhost:8080/resources/test/1%3B2%3B3</a></p> <p>Update: the <a href="http://java.net/projects/jersey/sources/svn/content/tags/jersey-1.3/jersey/changes.txt" rel="noreferrer">changelog for Jersey 1.3</a> include this information:</p> <blockquote> <p>Fixed issue 540<br> <a href="http://java.net/jira/browse/JERSEY-540" rel="noreferrer">http://java.net/jira/browse/JERSEY-540</a> Parameterized types of List/Set/SortedSet are supported for parameters, for example @QueryParam("d") List>, if there is a StringReaderProvider registered that supports the type List.</p> </blockquote> <p>I'll check out StringReaderProvider based on this post <a href="http://comments.gmane.org/gmane.comp.java.jersey.user/7545" rel="noreferrer">http://comments.gmane.org/gmane.comp.java.jersey.user/7545</a></p>
 

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