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:
public interface PathSegment {

    /**
     * Get the path segment.
     * <p>
     * @return the path segment
     */
    String getPath();
    /**
     * Get a map of the matrix parameters associated with the path segment
     * @return the map of matrix parameters
     */
    MultivaluedMap<String, String> getMatrixParameters();
    
}

Copy to Clipboard Toggle word wrap
RESTEasy can inject a PathSegment instead of a value with your @PathParam.
   @GET
   @Path("/book/{id}")
   public String getBook(@PathParam("id") PathSegment id) {...}

Copy to Clipboard Toggle word wrap
This is particularly useful when you have multiple @PathParams 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
Copy to Clipboard Toggle word wrap
A matrix parameter represents a resource that can be addressed by its attributes as well as its raw ID.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat