@Bean public class UriContext extends Object
A typical request against a URL takes the following form:
http://host:port/context-root/servlet-path/path-info | authority | context | resource | path | +--------------------------------------------------+
This class allows you to convert URL strings to absolute (e.g.
Modifier and Type | Field and Description |
---|---|
String |
authority |
String |
contextRoot |
static UriContext |
DEFAULT
Default URI context.
|
String |
parentPath |
String |
pathInfo |
String |
servletPath |
Constructor and Description |
---|
UriContext()
Default constructor.
|
UriContext(String s)
String constructor.
|
UriContext(String authority,
String contextRoot,
String servletPath,
String pathInfo)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getAbsoluteAuthority()
Returns the absolute URI of just the authority portion of this URI context.
|
String |
getAbsoluteContextRoot()
Returns the absolute URI of the context-root portion of this URI context.
|
String |
getAbsolutePathInfo()
Returns the absolute URI of the path portion of this URI context.
|
String |
getAbsolutePathInfoParent()
Returns the parent of the URL returned by
getAbsolutePathInfo() . |
String |
getAbsoluteServletPath()
Returns the absolute URI of the resource portion of this URI context.
|
String |
getAbsoluteServletPathParent()
Returns the parent of the URL returned by
getAbsoluteServletPath() . |
String |
getRootRelativeContextRoot()
Returns the root-relative URI of the context portion of this URI context.
|
String |
getRootRelativePathInfo()
Returns the root-relative URI of the path portion of this URI context.
|
String |
getRootRelativePathInfoParent()
Returns the parent of the URL returned by
getRootRelativePathInfo() . |
String |
getRootRelativeServletPath()
Returns the root-relative URI of the resource portion of this URI context.
|
String |
getRootRelativeServletPathParent()
Returns the parent of the URL returned by
getRootRelativeServletPath() . |
String |
toString() |
public static final UriContext DEFAULT
No information about authority, servlet-root, context-root, or path-info is known.
public final String contextRoot
public final String servletPath
public final String parentPath
@BeanConstructor public UriContext(@Name(value="authority") String authority, @Name(value="contextRoot") String contextRoot, @Name(value="servletPath") String servletPath, @Name(value="pathInfo") String pathInfo)
Leading and trailing slashes are trimmed of all parameters.
Any parameter can be
authority
- The authority portion of URL (e.g. contextRoot
- The context root of the application (e.g. servletPath
- The servlet path (e.g. pathInfo
- The path info (e.g. public UriContext()
All
public UriContext(String s) throws ParseException
Input string is a JSON object with the following format:
s
- The input string.
ParseException
- If input string is not a valid JSON object.public String getAbsoluteAuthority()
Example:
If the authority is null/empty, returns
public String getAbsoluteContextRoot()
Example:
public String getRootRelativeContextRoot()
Example:
public String getAbsoluteServletPath()
Example:
public String getRootRelativeServletPath()
Example:
public String getAbsoluteServletPathParent()
getAbsoluteServletPath()
.getAbsoluteServletPath()
.public String getRootRelativeServletPathParent()
getRootRelativeServletPath()
.getRootRelativeServletPath()
.public String getAbsolutePathInfo()
Example:
public String getRootRelativePathInfo()
Example:
public String getAbsolutePathInfoParent()
getAbsolutePathInfo()
.getAbsolutePathInfo()
.public String getRootRelativePathInfoParent()
getRootRelativePathInfo()
.getRootRelativePathInfo()
.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.