Mehdi Ben Haj Abbes wrote:
> Hi,
>
> Please I want to know how can I specify a path template variable so it
> can accept a path (
>
> for example : if I make a request to bseURI/machin/containers/smth and
> in machinResource I have @Path("{container}"), @PathParam("container")
> will return containers/smth
>
As you have undoubtedly discovered, the "container" parameter in this
case will contain "containers". The typical pattern in JAX-RS is to use
a sub-resource class to match the next element, or a second path on an
individual method:
> I do not want to specify @Path as @Path("{part1}/{part2}"),
Just out of curiousity, why do you not want to do this? You can always
concatenate the parts back together if you really need
"containers/smith" inside the application.
Personally, I would recommend splitting things up:
@Path("{container}")
public class MyResource {
...
@Path("{name}"
@GET
public Response myGetMethod(@PathParam("container") String
container,
@PathParam("name") String name) {
String combo = container + "/" + name; // If you really need
it combined
...
}
Craig
> I tried to submit an encoded URI with %2F but I get 400 status code
>
> thanks and regards
> --
> Mehdi BEN HAJ ABBES
>