Note
As of 5.1, methods in this class do not extract
"Forwarded" and "X-Forwarded-*" headers that specify the
client-originated address. Please, use
ForwardedHeaderFilter, or similar from the underlying server, to extract
and use such headers, or to discard them.
| Modifier and Type | Field and Description |
|---|---|
| private String |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | ServletUriComponentsBuilder(ServletUriComponentsBuilder
the other builder to copy from other)Create a deep copy of the given ServletUriComponentsBuilder. |
| Modifier and Type | Method and Description |
|---|---|
| public ServletUriComponentsBuilder | cloneBuilder()
Overrides org. Clone this |
| public static ServletUriComponentsBuilder | fromContextPath(HttpServletRequest request)
Prepare a builder from the host, port, scheme, and context path of the given HttpServletRequest. |
| public static ServletUriComponentsBuilder | fromCurrentContextPath()
Same as |
| public static ServletUriComponentsBuilder | fromCurrentRequest()
Same as |
| public static ServletUriComponentsBuilder | fromCurrentRequestUri()
Same as |
| public static ServletUriComponentsBuilder | fromCurrentServletMapping()
Same as |
| public static ServletUriComponentsBuilder | fromRequest(HttpServletRequest request)
Prepare a builder by copying the scheme, host, port, path, and query string of an HttpServletRequest. |
| public static ServletUriComponentsBuilder | fromRequestUri(HttpServletRequest request)
Prepare a builder from the host, port, scheme, and path (but not the query) of the HttpServletRequest. |
| public static ServletUriComponentsBuilder | fromServletMapping(HttpServletRequest request)
Prepare a builder from the host, port, scheme, context path, and servlet mapping of the given HttpServletRequest. |
| protected static HttpServletRequest | |
| private static ServletUriComponentsBuilder | initFromRequest(HttpServletRequest request)
Initialize a builder with a scheme, host,and port (but not path and query). |
| private void | |
| public String | Returns: the removed path extension for possible re-use, ornullRemove any path extension from the |
| originalPath | back to summary |
|---|---|
| private String originalPath
| |
| ServletUriComponentsBuilder | back to summary |
|---|---|
| protected ServletUriComponentsBuilder() Default constructor. Protected to prevent direct instantiation. | |
| ServletUriComponentsBuilder | back to summary |
|---|---|
| protected ServletUriComponentsBuilder(ServletUriComponentsBuilder other) Create a deep copy of the given ServletUriComponentsBuilder.
| |
| cloneBuilder | back to summary |
|---|---|
| public ServletUriComponentsBuilder cloneBuilder() Overrides org. Doc from org. Clone this
| |
| fromContextPath | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromContextPath(HttpServletRequest request) Prepare a builder from the host, port, scheme, and context path of the given HttpServletRequest. | |
| fromCurrentContextPath | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromCurrentContextPath() Same as | |
| fromCurrentRequest | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromCurrentRequest() Same as | |
| fromCurrentRequestUri | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromCurrentRequestUri() Same as | |
| fromCurrentServletMapping | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromCurrentServletMapping() Same as | |
| fromRequest | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromRequest(HttpServletRequest request) Prepare a builder by copying the scheme, host, port, path, and query string of an HttpServletRequest. | |
| fromRequestUri | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromRequestUri(HttpServletRequest request) Prepare a builder from the host, port, scheme, and path (but not the query) of the HttpServletRequest. | |
| fromServletMapping | back to summary |
|---|---|
| public static ServletUriComponentsBuilder fromServletMapping(HttpServletRequest request) Prepare a builder from the host, port, scheme, context path, and servlet mapping of the given HttpServletRequest. If the servlet is mapped by name, e.g. | |
| getCurrentRequest | back to summary |
|---|---|
| protected static HttpServletRequest getCurrentRequest() Obtain current request through | |
| initFromRequest | back to summary |
|---|---|
| private static ServletUriComponentsBuilder initFromRequest(HttpServletRequest request) Initialize a builder with a scheme, host,and port (but not path and query). | |
| initPath | back to summary |
|---|---|
| private void initPath(String path) | |
| removePathExtension | back to summary |
|---|---|
| public String removePathExtension() Remove any path extension from the
GET http://www.foo.example/rest/books/6.json
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request);
String ext = builder.removePathExtension();
String uri = builder.path("/pages/1.{ext}").buildAndExpand(ext).toUriString();
assertEquals("http://www.foo.example/rest/books/6/pages/1.json", result);
| |