类 DefaultUriBuilderFactory
- java.lang.Object
- org.springframework.web.util.DefaultUriBuilderFactory
- 所有已实现的接口:
UriBuilderFactory,UriTemplateHandler
public class DefaultUriBuilderFactory extends Object implements UriBuilderFactory
UriBuilderFactorythat relies onUriComponentsBuilderfor the actual building of the URI.Provides options to create
UriBuilderinstances with a common base URI, alternative encoding mode strategies, among others.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
- 另请参阅:
UriComponentsBuilder
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classDefaultUriBuilderFactory.EncodingModeEnum to represent multiple URI encoding strategies.
构造器概要
构造器 构造器 说明 DefaultUriBuilderFactory()Default constructor without a base URI.DefaultUriBuilderFactory(String baseUriTemplate)Constructor with a base URI.DefaultUriBuilderFactory(UriComponentsBuilder baseUri)Variant ofDefaultUriBuilderFactory(String)with aUriComponentsBuilder.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 UriBuilderbuilder()Create a URI builder with default settings.URIexpand(String uriTemplate, Object... uriVars)Expand the given URI template with an array of URI variables.URIexpand(String uriTemplate, Map<String,?> uriVars)Expand the given URI template with a map of URI variables.Map<String,?>getDefaultUriVariables()Return the configured default URI variable values.DefaultUriBuilderFactory.EncodingModegetEncodingMode()Return the configured encoding mode.voidsetDefaultUriVariables(Map<String,?> defaultUriVariables)Provide default URI variable values to use when expanding URI templates with a Map of variables.voidsetEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)Set theencoding modeto use.voidsetParsePath(boolean parsePath)Whether to parse the input path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT, which ensures that URI variables in the path are encoded according to path segment rules and for example a '/' is encoded.booleanshouldParsePath()Whether to parse the path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT.UriBuilderuriString(String uriTemplate)Initialize a builder with the given URI template.
构造器详细资料
DefaultUriBuilderFactory
public DefaultUriBuilderFactory()
Default constructor without a base URI.The target address must be specified on each UriBuilder.
DefaultUriBuilderFactory
public DefaultUriBuilderFactory(String baseUriTemplate)
Constructor with a base URI.The given URI template is parsed via
UriComponentsBuilder.fromUriString(java.lang.String)and then applied as a base URI to every UriBuilder viaUriComponentsBuilder.uriComponents(org.springframework.web.util.UriComponents)unless the UriBuilder itself was created with a URI template that already has a target address.- 参数:
baseUriTemplate- the URI template to use a base URL
DefaultUriBuilderFactory
public DefaultUriBuilderFactory(UriComponentsBuilder baseUri)
Variant ofDefaultUriBuilderFactory(String)with aUriComponentsBuilder.
方法详细资料
setEncodingMode
public void setEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)
Set theencoding modeto use.By default this is set to
EncodingMode.TEMPLATE_AND_VALUES.Note: Prior to 5.1 the default was
EncodingMode.URI_COMPONENTtherefore theWebClientRestTemplatehave switched their default behavior.- 参数:
encodingMode- the encoding mode to use
getEncodingMode
public DefaultUriBuilderFactory.EncodingMode getEncodingMode()
Return the configured encoding mode.
setDefaultUriVariables
public void setDefaultUriVariables(@Nullable Map<String,?> defaultUriVariables)
Provide default URI variable values to use when expanding URI templates with a Map of variables.- 参数:
defaultUriVariables- default URI variable values
getDefaultUriVariables
public Map<String,?> getDefaultUriVariables()
Return the configured default URI variable values.
setParsePath
public void setParsePath(boolean parsePath)
Whether to parse the input path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT, which ensures that URI variables in the path are encoded according to path segment rules and for example a '/' is encoded.By default this is set to
true.- 参数:
parsePath- whether to parse the path into path segments
shouldParsePath
public boolean shouldParsePath()
Whether to parse the path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT.
expand
public URI expand(String uriTemplate, Map<String,?> uriVars)
从接口复制的说明:UriTemplateHandlerExpand the given URI template with a map of URI variables.- 指定者:
expand在接口中UriTemplateHandler- 参数:
uriTemplate- the URI templateuriVars- variable values- 返回:
- the created URI instance
expand
public URI expand(String uriTemplate, Object... uriVars)
从接口复制的说明:UriTemplateHandlerExpand the given URI template with an array of URI variables.- 指定者:
expand在接口中UriTemplateHandler- 参数:
uriTemplate- the URI templateuriVars- variable values- 返回:
- the created URI instance
uriString
public UriBuilder uriString(String uriTemplate)
从接口复制的说明:UriBuilderFactoryInitialize a builder with the given URI template.- 指定者:
uriString在接口中UriBuilderFactory- 参数:
uriTemplate- the URI template to use- 返回:
- the builder instance
builder
public UriBuilder builder()
从接口复制的说明:UriBuilderFactoryCreate a URI builder with default settings.- 指定者:
builder在接口中UriBuilderFactory- 返回:
- the builder instance