类 ServletUriComponentsBuilder
java.lang.Object
cn.taketoday.web.util.UriComponentsBuilder
cn.taketoday.web.servlet.support.ServletUriComponentsBuilder
- 所有已实现的接口:
UriBuilder,Cloneable
UriComponentsBuilder with additional static factory methods to create links
based on the current HttpServletRequest.
Note: 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.
- 从以下版本开始:
- 4.0 2022/4/7 21:30
- 作者:
- Rossen Stoyanchev, Harry Yang
-
字段概要
字段 -
构造器概要
构造器限定符构造器说明protectedDefault constructor.protectedCreate a deep copy of the given ServletUriComponentsBuilder. -
方法概要
修饰符和类型方法说明Clone thisUriComponentsBuilder.static ServletUriComponentsBuilderfromContextPath(HttpServletRequest request) Prepare a builder from the host, port, scheme, and context path of the given HttpServletRequest.static ServletUriComponentsBuilderSame asfromContextPath(HttpServletRequest)except the request is obtained throughRequestContextHolder.static ServletUriComponentsBuilderSame asfromRequest(HttpServletRequest)except the request is obtained throughRequestContextHolder.static ServletUriComponentsBuilderSame asfromRequestUri(HttpServletRequest)except the request is obtained throughRequestContextHolder.static ServletUriComponentsBuilderSame asfromServletMapping(HttpServletRequest)except the request is obtained throughRequestContextHolder.static ServletUriComponentsBuilderfromRequest(HttpServletRequest request) Prepare a builder by copying the scheme, host, port, path, and query string of an HttpServletRequest.static ServletUriComponentsBuilderfromRequestUri(HttpServletRequest request) Prepare a builder from the host, port, scheme, and path (but not the query) of the HttpServletRequest.static ServletUriComponentsBuilderfromServletMapping(HttpServletRequest request) Prepare a builder from the host, port, scheme, context path, and servlet mapping of the given HttpServletRequest.protected static HttpServletRequestObtain current request throughRequestContextHolder.private static ServletUriComponentsBuilderinitFromRequest(HttpServletRequest request) Initialize a builder with a scheme, host,and port (but not path and query).private voidRemove any path extension from therequestURI.从类继承的方法 cn.taketoday.web.util.UriComponentsBuilder
build, build, build, build, buildAndExpand, buildAndExpand, clone, encode, encode, fragment, fromHttpRequest, fromHttpUrl, fromOriginHeader, fromPath, fromUri, fromUriString, host, newInstance, path, pathSegment, port, port, query, queryParam, queryParam, queryParamIfPresent, queryParams, replacePath, replaceQuery, replaceQueryParam, replaceQueryParam, replaceQueryParams, scheme, schemeSpecificPart, toUriString, uri, uriComponents, uriVariables, userInfo
-
字段详细资料
-
originalPath
-
-
构造器详细资料
-
ServletUriComponentsBuilder
protected ServletUriComponentsBuilder()Default constructor. Protected to prevent direct instantiation. -
ServletUriComponentsBuilder
Create a deep copy of the given ServletUriComponentsBuilder.- 参数:
other- the other builder to copy from
-
-
方法详细资料
-
fromContextPath
Prepare a builder from the host, port, scheme, and context path of the given HttpServletRequest. -
fromServletMapping
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.
"/main/*", the path will end with "/main". If the servlet is mapped otherwise, e.g."/"or"*.do", the result will be the same as if callingfromContextPath(HttpServletRequest). -
fromRequestUri
Prepare a builder from the host, port, scheme, and path (but not the query) of the HttpServletRequest. -
fromRequest
Prepare a builder by copying the scheme, host, port, path, and query string of an HttpServletRequest. -
initFromRequest
Initialize a builder with a scheme, host,and port (but not path and query). -
fromCurrentContextPath
Same asfromContextPath(HttpServletRequest)except the request is obtained throughRequestContextHolder. -
fromCurrentServletMapping
Same asfromServletMapping(HttpServletRequest)except the request is obtained throughRequestContextHolder. -
fromCurrentRequestUri
Same asfromRequestUri(HttpServletRequest)except the request is obtained throughRequestContextHolder. -
fromCurrentRequest
Same asfromRequest(HttpServletRequest)except the request is obtained throughRequestContextHolder. -
getCurrentRequest
Obtain current request throughRequestContextHolder. -
initPath
-
removePathExtension
Remove any path extension from therequestURI. This method must be invoked before any calls toUriComponentsBuilder.path(String)orUriComponentsBuilder.pathSegment(String...).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);- 返回:
- the removed path extension for possible re-use, or
null
-
cloneBuilder
从类复制的说明:UriComponentsBuilderClone thisUriComponentsBuilder.- 覆盖:
cloneBuilder在类中UriComponentsBuilder- 返回:
- the cloned
UriComponentsBuilderobject
-