- A scheme. The scheme identifies the protocol to be used to access the resource on the Internet. It can be HTTP (without SSL) or HTTPS (with SSL).
- A host. The host name identifies the host that holds the resource. For example,
www.example.com
. A server provides services in the name of the host, but hosts and servers do not have a one-to-one mapping. Refer to Host names.Host names can also be followed by a port number. Refer to Port numbers. Well-known port numbers for a service are normally omitted from the URL. Most servers use the well-known port numbers for HTTP and HTTPS , so most HTTP URLs omit the port number.
- A path. The path identifies the specific resource in the host that the web client wants to access. For example,
/software/htp/cics/index.html
. - A query string. If a query string is used, it follows the path component, and provides a string of information that the resource can use for some purpose (for example, as parameters for a search or as data to be processed). The query string is usually a string of name and value pairs; for example,
term=bluebird
. Name and value pairs are separated from each other by an ampersand (&); for example,term=bluebird&source=browser-search
.
scheme://host:port/path?query
- The scheme is followed by a colon and two forward slashes.
- If a port number is specified, that number follows the host name, separated by a colon.
- The path name begins with a single forward slash.
- If a query string is specified, it is preceded by a question mark.
I like to think of the term "scheme" as the region of the URL that indicates the "protocol".
the scheme
┌───┐
https://www.google.com/
└───┘
the specific protocol
URL是URI的一个子集。它是Uniform Resource Locator的缩写,译为“统一资源定位 符”。
通俗地说,URL是Internet上描述信息资源的字符串,主要用在各种WWW客户程序和服务器程序上。
采用URL可以用一种统一的格式来描述各种信息资源,包括文件、服务器的地址和目录等。URL是URI概念的一种实现方式。
URL的一般格式为(带方括号[]的为可选项):
protocol :// hostname[:port] / path / [;parameters][?query]#fragment
URL的格式由三部分组成:
①第一部分是协议(或称为服务方式)。
②第二部分是存有该资源的主机IP地址(有时也包括端口号)。
③第三部分是主机资源的具体地址,如目录和文件名等。
————————————————
版权声明:本文为CSDN博主「风一样的美代码」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_32595453/java/article/details/80563142