类 UriComponents
- 所有已实现的接口:
Serializable
URI, but with more powerful encoding options and support for
URI template variables.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private static final recordURI template variables backed by a map.static interfaceDefines the contract for URI Template variables.private static classURI template variables backed by a variable argument array. -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected abstract voidSet all components of the given UriComponentsBuilder.final UriComponentsencode()Invoke this after expanding URI variables to encode the resulting URI component values.abstract UriComponentsA variant ofencode()with a charset other than "UTF-8".final UriComponentsexpand(UriComponents.UriTemplateVariables uriVariables) Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.final UriComponentsReplace all URI template variables with the values from a given array.final UriComponentsReplace all URI template variables with the values from a given map.(专用程序包) abstract UriComponentsexpandInternal(UriComponents.UriTemplateVariables uriVariables) Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.(专用程序包) static StringexpandUriComponent(String source, UriComponents.UriTemplateVariables uriVariables) (专用程序包) static StringexpandUriComponent(String source, UriComponents.UriTemplateVariables uriVariables, UnaryOperator<String> encoder) final StringReturn the fragment.abstract StringgetHost()Return the host.abstract StringgetPath()Return the path.Return the list of path segments.abstract intgetPort()Return the port.abstract StringgetQuery()Return the query.Return the map of query parameters.final StringReturn the scheme.abstract StringReturn the scheme specific part.abstract StringReturn the user info.private static StringgetVariableName(String match) private static StringgetVariableValueAsString(Object variableValue) abstract UriComponentsNormalize the path removing sequences like "path/..".private static StringsanitizeSource(String source) Remove nested "{}" such as in URI vars with regular expressions.final StringtoString()A simple pass-through totoUriString().abstract URItoUri()Create aURIfrom this instance as follows:abstract StringConcatenate all URI components to return the fully formed URI String.
-
字段详细资料
-
NAMES_PATTERN
Captures URI template variable names. -
scheme
-
fragment
-
-
构造器详细资料
-
UriComponents
-
-
方法详细资料
-
getScheme
Return the scheme. Can benull. -
getFragment
Return the fragment. Can benull. -
getSchemeSpecificPart
Return the scheme specific part. Can benull. -
getUserInfo
Return the user info. Can benull. -
getHost
Return the host. Can benull. -
getPort
public abstract int getPort()Return the port.-1if no port has been set. -
getPath
Return the path. Can benull. -
getPathSegments
Return the list of path segments. Empty if no path has been set. -
getQuery
Return the query. Can benull. -
getQueryParams
Return the map of query parameters. Empty if no query has been set. -
encode
Invoke this after expanding URI variables to encode the resulting URI component values.In comparison to
UriComponentsBuilder.encode(), this method only replaces non-ASCII and illegal (within a given URI component type) characters, but not characters with reserved meaning. For most cases,UriComponentsBuilder.encode()is more likely to give the expected result. -
encode
A variant ofencode()with a charset other than "UTF-8".- 参数:
charset- the charset to use for encoding- 另请参阅:
-
expand
Replace all URI template variables with the values from a given map.The given map keys represent variable names; the corresponding values represent variable values. The order of variables is not significant.
- 参数:
uriVariables- the map of URI variables- 返回:
- the expanded URI components
-
expand
Replace all URI template variables with the values from a given array.The given array represents variable values. The order of variables is significant.
- 参数:
uriVariableValues- the URI variable values- 返回:
- the expanded URI components
-
expand
Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.- 参数:
uriVariables- the URI template values- 返回:
- the expanded URI components
-
expandInternal
Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.- 参数:
uriVariables- the URI template values- 返回:
- the expanded URI components
-
normalize
Normalize the path removing sequences like "path/..". Note that normalization is applied to the full path, and not to individual path segments.- 另请参阅:
-
StringUtils.cleanPath(String)
-
toUriString
Concatenate all URI components to return the fully formed URI String.This method amounts to simple String concatenation of the current URI component values and as such the result may contain illegal URI characters, for example if URI variables have not been expanded or if encoding has not been applied via
UriComponentsBuilder.encode()orencode(). -
toUri
Create aURIfrom this instance as follows:If the current instance is
encoded, form the full URI String viatoUriString(), and then pass it to the single argumentURIconstructor which preserves percent encoding.If not yet encoded, pass individual URI component values to the multi-argument
URIconstructor which quotes illegal characters that cannot appear in their respective URI component. -
toString
A simple pass-through totoUriString(). -
copyToUriComponentsBuilder
Set all components of the given UriComponentsBuilder. -
expandUriComponent
@Nullable static String expandUriComponent(@Nullable String source, UriComponents.UriTemplateVariables uriVariables) -
expandUriComponent
@Nullable static String expandUriComponent(@Nullable String source, UriComponents.UriTemplateVariables uriVariables, @Nullable UnaryOperator<String> encoder) -
sanitizeSource
Remove nested "{}" such as in URI vars with regular expressions. -
getVariableName
-
getVariableValueAsString
-