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..."
- What makes a URI a URL is of course the "access mechanism" and "network location". e.g.
http://
or ftp:// - .
URN is part of the unique identifier, which is a special name.
- Let’s take a look at an example, which is also from an authoritative RFC:
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
It’s time to answer the question:
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.Map<String,String[]> getParameterMap() 获得所有的内容,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!

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.