Home>Article>Web Front-end> What is the difference between URL and URI?
When I first learned the http protocol, I was confused by these two similar terms. I checked a lot of information and finally figured it out. (It’s still in English when looking for information, it’s reliable...).
There have been many technical debates, the most interesting of which is probably the question of what the web address should be called. This is usually the case: someone calls the content of the address bar "URL". At this time, some people get excited: "No! In fact, the URI was..."
The reaction to this kind of correction is usually There are also several situations where the petty person just thinks that this person should leave quickly, the calm person shrugs his shoulders and agrees, and the angry person just draws a knife and fights, okay? As for this article, it only provides a simple summary of this. After all, you have to get down to the point of making fun of each other, right? URI, URL, URN As you can see from the picture above, there are three different concepts: URI, URL, and URN. When discussing such a problem, the best way is to go back to the starting point. Here we are in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax collects some information: "A Uniform Resource Identifier (URI) is a compact string used to identify abstract or physical resources." "A URI can be further divided into a locator, a name, or both. The term "Uniform Resource Locator" (URL) is a subset of a URI that, in addition to identifying a resource, also provides a primary access to locating that resource Mechanism (such as its network "location") " Then our omniscient Wikipedia digests this paragraph very well and describes it more vividly: "URI can be divided into URL, URN, or something that has both locators and names properties. URN acts like a person's name, and URL acts like a person's address. In other words: URN determines the identity of something, and URL provides a way to find it. ” We can get some conclusions from these descriptions: First of all, URL is a type of URI (you can see it through that picture Bar). So if someone tells you that a URL is not a URI, he or she is wrong. But not all URIs are URLs. Just like butterflies can fly, but not all butterflies can fly. What do you want flies to think?http://
orURN is part of the unique identifier, which is a special name.
ftp://ftp.is .co.za/rfc/rfc1808.txt
(also a URL because of the protocol)##http://www.ietf.org/rfc/rfc2396 .txt
(also a URL because of the protocol)
ldap://[2001:db8::7]/c=GB?objectClass?one
(also a URL because of the protocol)
mailto:John.Doe@example.com
(also a URL because of the protocol)
news:comp.infosystems.www.servers.unix
(also a URL because of the protocol)
tel:+1-816-555-1212
telnet://192.0.2.16:80/
(also a URL because of the protocol)
urn:oasis:names:specification:docbook:dtd:xml:4.1.2
These are all URI, some of which are URLs. Which ones? Those that provide access mechanisms.Summary
When we replace the web address Which one is more accurate, URI or URL?
Based on a lot of articles I've read, including RFCs, I'd say URIs are more accurate.
Don’t worry, I have my reasons:
The URI we often use is not a URL in the strict technical sense. For example: the file you need is at
files.hp.com. This is a URI, but not a URL – the system may respond correctly to many protocols and ports.
3 request * request对象,tomcat根据http协议的请求的内容,将相应的数据封装到request对象中。 * request和response必须是成对出现,先有的request,再有的response * 接口:javax.servlet.http.HttpServletRequest extends javax.servlet.ServletRequest * 实现类:tomcat实现,并在请求时,tomcat创建 。 * 请求行 * 入口:http://localhost:8080/day05/demo/pathRequestServlet?username=jack&password=1234 * 请求方式 request.getMethod(); * 路径 // * 请求资源路径 // 1 获得servlet路径,web.xml配置的url-pattern【★★★】 String servletPath = request.getServletPath(); System.out.println(" 1 servletPath -->" + servletPath); //--> /demo/pathRequestServlet //2 获得发布到tomcat时的项目名称【★★★】 String contextPath = request.getContextPath(); System.out.println(" 2 contextPath -->" + contextPath); //--> /day05 //3 获得请求行中的资源路径 String requestURI = request.getRequestURI(); System.out.println(" 3 requestURI -->" + requestURI);//-->/day05/demo/pathRequestServlet //4 获得请求URL(地址栏书写) String requestURL = request.getRequestURL().toString(); System.out.println(" 4 requestURL -->" + requestURL);//-->http://localhost:8080/day05/demo/pathRequestServlet // *** 以上都不获得get请求的参数 //5 获得get请求的参数,获得的是所有参数的一个字符串 String queryString = request.getQueryString(); System.out.println(" 5 queryString -->" + queryString); //-->username=jack&password=1234 * 协议 request.getProtocol(); * 请求头 * java.lang.String getHeader(java.lang.String name) 获得指定名称的头信息(一条)【★★★】 * long getDateHeader(java.lang.String name) 获得特殊数据,时间 * int getIntHeader(java.lang.String name) 获得特殊数据,整型 * java.util.Enumeration getHeaderNames() 获得所有的请求头的名称 * java.util.Enumeration getHeaders(java.lang.String name) 获得指定名称头的所有内容 * 实例:防盗链,(不能直接访问 /refererTwoServlet) * 请求体 * ServletInputStream getInputStream() 获得请求体的所有内容。(之后讲,文件上传) * 核心API * 属性操作 * xxxAttribute (set / get / remove) 服务器端【★★★】 * 获得参数 * 获得浏览器 发送给 服务器端的参数(Parameter) * API【★★★】 * 实例:url?username=jack&username=rose&username=tom&password=1234 * getParameter(java.lang.String name) 获得指定参数的第一个值,如果数据不存在获得null 。 * 例如:getParameter("username") 获得 jack * java.lang.String[] getParameterValues(java.lang.String name) 获得指定参数的所有的值。 * 例如:getParameterValues("username") ,获得[jack,rose,tom] * java.util.MapgetParameterMap() 获得所有的内容,key 参数的名称 ,value 该参数的所有的值 * 例如:{username=[jack,rose,tom],password=[1234]} * 中文乱码 * POST请求【★★★】 * 设置 setCharacterEncoding(java.lang.String env) ,设置字符编码 * GET请求 * new String(username.getBytes("ISO-8859-1"), "字符集");
The above is the detailed content of What is the difference between URL and URI?. For more information, please follow other related articles on the PHP Chinese website!