Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
51.2. Working with the full request URI
Abstract
UriInfo
object. The UriInfo
interface provides functions for decomposing the URI in a number of ways. It can also provide the URI as a UriBuilder
object that allows you to construct URIs to return to clients.
51.2.1. Injecting the URI information Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
UriInfo
object is decorated with the @Context
annotation, the URI context for the current request is injected into the UriInfo
object.
Example Copia collegamentoCollegamento copiato negli appunti!
Example 51.1. Injecting the URI context into a class field
51.2.2. Working with the URI Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
UriInfo
interface provides methods for accessing the parts of the URI:
- the base URI
- the resource path
- the full URI
Getting the Base URI Copia collegamentoCollegamento copiato negli appunti!
@Path
annotations. For example if a service implementing the resource defined in Example 46.5, “Disabling URI decoding” were published to http://fusesource.org and a request was made on http://fusesource.org/montersforhire/nightstalker?12 the base URI would be http://fusesource.org.
Getting the path Copia collegamentoCollegamento copiato negli appunti!
rootPath
— /monstersforhire/getterPath
— /mostersforhire/nightstalkerTheGET
request was made on /monstersforhire/nightstalker.putterPath
— /mostersforhire/911ThePUT
request was made on /monstersforhire/911.
Example 51.2. Getting a resource's path
Getting the full request URI Copia collegamentoCollegamento copiato negli appunti!
getRequestUri()
methods would return http://fusesource.org/montersforhire/nightstalker?12. The getAbsolutePath()
method would return http://fusesource.org/montersforhire/nightstalker.
51.2.3. Getting the value of URI template variables Copia collegamentoCollegamento copiato negli appunti!
Overview Copia collegamentoCollegamento copiato negli appunti!
Methods for getting the path parameters Copia collegamentoCollegamento copiato negli appunti!
UriInfo
interface provides two methods, shown in Example 51.3, “Methods for returning path parameters from the URI context”, that return a list of the path parameters.
Example 51.3. Methods for returning path parameters from the URI context
MultivaluedMap<java.lang.String, java.lang.String> getPathParameters();
MultivaluedMap<java.lang.String, java.lang.String> getPathParameters(boolean decode);
getPathParameters()
method that does not take any parameters automatically decodes the path parameters. If you want to disable URI decoding use getPathParameters(false)
.
color
and note
.
Example Copia collegamentoCollegamento copiato negli appunti!
Example 51.4. Extracting path parameters from the URI context