Questo contenuto non è disponibile nella lingua selezionata.

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();
    
}

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

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
A matrix parameter represents a resource that can be addressed by its attributes as well as its raw ID.
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima