类 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, 序列化表格
    • 方法详细资料

      • getPort

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

        public abstract List<StringgetPathSegments()
        Return the list of path segments. Empty if no path has been set.
      • 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()
        Concatenate all URI components to return the fully formed URI String.

        This method does nothing more than a simple concatenation based on current values. That means it could produce different results if invoked before vs after methods that can change individual values such as encode, expand, or normalize.

      • toUri

        public abstract URI toUri()
        Create a URI from this instance as follows:

        If the current instance is encoded, form the full URI String via toUriString(), and then pass it to the single argument URI constructor which preserves percent encoding.

        If not yet encoded, pass individual URI component values to the multi-argument URI constructor which quotes illegal characters that cannot appear in their respective URI component.