Path
Relative path
The first character in a URL is not "/"
Request.getrequestdispatcher ("B");
Relative to the location of the code, it refers to the location of the Java file.
Absolute path
The first character in a URL is not ""
Request.getrequestdispatcher ("/b")
Front desk
/represents the root directory of the server, note: is the root directory of the server
Examples of Use:
HTML page, JSP page, redirect
"ip:port/" Http://localhost:8080/webapps
Background
/represents the root directory of the project note: is the root directory of the project
Examples of Use:
Request.getrequestdispatcher ("B")
Xml
<url-pattern>/a</url-pattern>
http://localhost:8080/helloWorld/a
Webapps/helloworld---Hhtp://ip:port/helloworld
Servlet
The path is determined by the <url-pattern>/basic</url-pattern> in Web. xml
Http://localhost:8888/jd1508/basic
The path does not say that the directory where his class resides
Static resources
Its path is determined by the actual path of the project in which it resides, provided that it is not placed under Web-inf
Webapps/jd1508/html/a.html
Http://localhost:8888/jd1508/html/a.html
Server root directory WebApps--http://ip:port/
The root directory of the project webapps/jd1508--http://ip:port/jd1508
Toahtmlservlet
Http://localhost:8888/jd1508/toAHtml
--->
{Redirect, day7/a.html browser address changed}
Http://localhost:8888/jd1508/day7/a.html
A.html
---> Taservlet
Http://localhost:8888/jd1508/ta
Toahtmlservlet
Http://localhost:8888/jd1508/toAHtml
--->
{Internal jump,/day7/a.html browser address not changed}
Http://localhost:8888/jd1508/toAHtml
A.html
<a href= ". /a.html "></a>
---> Taservlet
Http://localhost:8888/jd1508/ta
Web Project Path Issues