Este conteúdo não está disponível no idioma selecionado.
4.2. @PathParam and PathSegment
The specification has a very simple abstraction for examining a fragment of the URI path being invoked on
javax.ws.rs.core.PathSegment
:
RESTEasy can inject a
PathSegment
instead of a value with your @PathParam
.
@GET @Path("/book/{id}") public String getBook(@PathParam("id") PathSegment id) {...}
@GET
@Path("/book/{id}")
public String getBook(@PathParam("id") PathSegment id) {...}
This is particularly useful when you have multiple
@PathParam
s that use matrix parameters. Matrix parameters are an arbitrary set of name-value pairs embedded in a URI path segment. The PathSegment
object fives you access to these parameters. See Chapter 7, @MatrixParam for further information.
An example of a matrix parameter:
GET http://host.com/library/book;name=EJB 3.0;author=Bill Burke
GET http://host.com/library/book;name=EJB 3.0;author=Bill Burke
A matrix parameter represents a resource that can be addressed by its attributes as well as its raw ID.