类 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 to URI, but with more powerful encoding options and support for URI template variables.
    从以下版本开始:
    3.1
    作者:
    Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev
    另请参阅:
    UriComponentsBuilder, 序列化表格
    • 方法详细资料

      • getHost

        public abstract String getHost()
        Return the host. Can be null.
      • getPort

        public abstract int getPort()
        Return the port. -1 if no port has been set.
      • getPath

        public abstract String getPath()
        Return the path. Can be null.
      • getPathSegments

        public abstract List<StringgetPathSegments()
        Return the list of path segments. Empty if no path has been set.
      • getQuery

        public abstract String getQuery()
        Return the query. Can be null.
      • encode

        public final UriComponents encode()
        Encode all URI components using their specific encoding rules, and returns the result as a new UriComponents instance. This method uses UTF-8 to encode.
        返回:
        the encoded URI components
      • 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
      • toUriString

        public abstract String toUriString()
        Return a URI String from this UriComponents instance.
      • toUri

        public abstract URI toUri()
        Return a URI from this UriComponents instance.