类 UriComponents
- java.lang.Object
- org.springframework.web.util.UriComponents
- 所有已实现的接口:
Serializable
public abstract class UriComponents extends Object implements Serializable
Represents an immutable collection of URI components, mapping component type to String values. Contains convenience getters for all components. Effectively similar toURI
, but with more powerful encoding options and support for URI template variables.- 从以下版本开始:
- 3.1
- 作者:
- Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev
- 另请参阅:
UriComponentsBuilder
, 序列化表格
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
UriComponents.UriTemplateVariables
Defines the contract for URI Template variables
构造器概要
构造器 限定符 构造器 说明 protected
UriComponents(String scheme, String fragment)
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract void
copyToUriComponentsBuilder(UriComponentsBuilder builder)
Set all components of the given UriComponentsBuilder.UriComponents
encode()
Encode all URI components using their specific encoding rules, and returns the result as a newUriComponents
instance.abstract UriComponents
encode(String encoding)
Encode all URI components using their specific encoding rules, and returns the result as a newUriComponents
instance.UriComponents
expand(Object... uriVariableValues)
Replace all URI template variables with the values from a given array.UriComponents
expand(Map<String,?> uriVariables)
Replace all URI template variables with the values from a given map.UriComponents
expand(UriComponents.UriTemplateVariables uriVariables)
Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables
.String
getFragment()
Return the fragment.abstract String
getHost()
Return the host.abstract String
getPath()
Return the path.abstract List<String>
getPathSegments()
Return the list of path segments.abstract int
getPort()
Return the port.abstract String
getQuery()
Return the query.abstract MultiValueMap<String,String>
getQueryParams()
Return the map of query parameters.String
getScheme()
Return the scheme.abstract String
getSchemeSpecificPart()
Return the scheme specific part.abstract String
getUserInfo()
Return the user info.abstract UriComponents
normalize()
Normalize the path removing sequences like "path/..".String
toString()
abstract URI
toUri()
Return aURI
from thisUriComponents
instance.abstract String
toUriString()
Return a URI String from thisUriComponents
instance.
构造器详细资料
UriComponents
protected UriComponents(String scheme, String fragment)
方法详细资料
getFragment
public final String getFragment()
Return the fragment. Can benull
.
getSchemeSpecificPart
public abstract String getSchemeSpecificPart()
Return the scheme specific part. Can benull
.
getUserInfo
public abstract String getUserInfo()
Return the user info. Can benull
.
getPort
public abstract int getPort()
Return the port.-1
if no port has been set.
getPathSegments
public abstract List<String> getPathSegments()
Return the list of path segments. Empty if no path has been set.
getQueryParams
public abstract MultiValueMap<String,String> getQueryParams()
Return the map of query parameters. Empty if no query has been set.
encode
public final UriComponents encode()
Encode all URI components using their specific encoding rules, and returns the result as a newUriComponents
instance. This method uses UTF-8 to encode.- 返回:
- the encoded URI components
encode
public abstract UriComponents encode(String encoding) throws UnsupportedEncodingException
Encode all URI components using their specific encoding rules, and returns the result as a newUriComponents
instance.- 参数:
encoding
- the encoding of the values contained in this map- 返回:
- the encoded URI components
- 抛出:
UnsupportedEncodingException
- if the given encoding is not supported
expand
public final UriComponents expand(Map<String,?> uriVariables)
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
public final UriComponents expand(Object... uriVariableValues)
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
public final UriComponents expand(UriComponents.UriTemplateVariables uriVariables)
Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables
.- 参数:
uriVariables
- the URI template values- 返回:
- the expanded URI components
normalize
public abstract UriComponents normalize()
Normalize the path removing sequences like "path/..".
toUriString
public abstract String toUriString()
Return a URI String from thisUriComponents
instance.
copyToUriComponentsBuilder
protected abstract void copyToUriComponentsBuilder(UriComponentsBuilder builder)
Set all components of the given UriComponentsBuilder.- 从以下版本开始:
- 4.2