你知道url,urn,uri的区别吗?

做java的以及网络相关开发的,这三个概念,URI,URL,URN估计经常碰到,而且,一直很混淆,

首先看看URL:

uniform resource locator, abbreviated URL, also known as web address, is a specific character string that constitutes a reference to a resource. In most web browsers, the URL of a web page is displayed on top inside an address bar. An example of a typical URL would be "http://en.example.org/wiki/Main_Page". A URL is technically a type of uniform resource identifier (URI), but in many technical documents and verbal discussions, URL is often used as a synonym for URI, and this is not considered a problem.[1]

这是维基百科里面定义的。URL就是web地址,表示一个资源的字串,URL就是一种URI,

Every URL consists of the following:

上面描述就是URL的构成,SCHEME,主机,端口号,以及资源的全局地址

In computing, a uniform resource identifier (URI) is a string of characters used to identify a name of a web resource. Such identification enables interaction with representations of the web resource over a network (typically the World Wide Web) using specific protocols. Schemes specifying a concrete syntax and associated protocols define each URI.

这是 URI地址,URI就是表示web资源的字串,就是标识资源的一种方式,通过名字或者地址,

再来 看URN

uniform resource name (URN) is the historical name for a uniform resource identifier (URI) that uses the urn: scheme.

这 就是URN定义,就是使用urn:这种schme的uri的历史名字。

最后 又在网络上收到的下面的对比:

URI

URI identifies a resource either by location, or a name, or both. More often than not, most of us use URIs that defines a location to a resource. The fact that a URI can identify a resources by both name and location has lead to a lot of the confusion in my opionion. A URI has two specializations known as URL and URN.

URN

A URI identifies a resource by name in a given namespace but not define how the resource maybe obtained. This type of URI is called a URN. You may see URNs used in XML Schema documents to define a namespace, usually using a syntax such as:

<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:example"

Here the targetNamespace use a URN. It defines an identifier to the namespace, but it does not define a location.

URL

A URL is a specialization of URI that defines the network location of a specific resource. Unlike a URN, the URL defines how the resource can be obtained. We use URLs every day in the form of http://damnhandy.com, etc. But a URL doesn’t have to be an HTTP URL, it can be ftp://damnhandy.com, smb://damnhandy.com, etc.

猜你喜欢

转载自ttxsj.iteye.com/blog/1956121