路径
相对路径
URL中第一个字符不为“/”
request.getRequestDispatcher("b");
相对于该代码所在的位置,指的是java文件的位置。
绝对路径
URL中第一个字符不为""
request.getRequestDispatcher("/b")
前台
/代表的是服务器的根目录,注意:是服务器的根目录
使用例子:
html页面,jsp页面,重定向
"ip:port/" http://localhost:8080/ webapps
后台
/代表的是项目的根目录 注意:是项目的根目录
使用例子:
request.getRequestDIspatcher("b")
web.xml
<url-pattern>/a</url-pattern>
http://localhost:8080/helloWorld/a
webapps/helloWorld ---hhtp://ip:port/helloWorld
Servlet
其路径由web.xml中的<url-pattern>/basic</url-pattern>
http://localhost:8888/jd1508/basic
路径并不是说他的类所在的目录
静态资源
其路径由其所在的项目的实际路径来决定,前提是没有放在WEB-INF下
webapps/jd1508/html/a.html
http://localhost:8888/jd1508/html/a.html
服务器根目录 webapps -- http://ip:port/
项目的根目录 webapps/jd1508 -- http://ip:port/jd1508
TOAHtmlServlet
http://localhost:8888/jd1508/toAHtml
--->
{ 重定向,day7/a.html 浏览器地址发生变化}
http://localhost:8888/jd1508/day7/a.html
a.html
---> TAServlet
http://localhost:8888/jd1508/ta
TOAHtmlServlet
http://localhost:8888/jd1508/toAHtml
--->
{ 内部跳转,/day7/a.html 浏览器地址不发生变化}
http://localhost:8888/jd1508/toAHtml
a.html
<a href="../a.html"></a>
---> TAServlet
http://localhost:8888/jd1508/ta
一个路径问题的小例子:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAD7CAIAAAA0MuU4AAAgAElEQVR4nO2df1QUZ5rv393c5L97j2edubPJOXsm12TdnPHeMRpktDcjnp3dIc6e3ezNuVHJxMFBUzPMZKMym42OEvyBiq1OajEkJgbQUaFVTECkxImkNQpiJiMgCmgPAYLyG2yBprvp7rz3j6queqvqreqG/l083/McT9Vbz/uj7A8vbxXv0w/C01VHhzWnuDil2JpTXNzRYZ12OyBQeIWmV62jw5pitaZbrZcuXTpy5HhKsRWwBsWJgmW66cxm0TDGOVZrerG12Fps7cixWovT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aZlSwEyzkqxJpF9V4e0chGPiLUHyyk6Jtfh8hNQtPT/AckdklPatJ30AAAAAElFTkSuQmCC" alt="" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>a.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<base target="http://127.0.0.1:8080/ServletDemo02">
</head> <body>
<!-- 需要访问到aServlet,怎么办呢?,第一种路径出现问题,表示 http://127.0.0.1:8080/aServlet-->
<a href="/aServlet">AServlet</a><br/>
<!-- 这种方式可以,最好是在jsp中使用,因为有时候你无法获知你的项目名 -->
<a href="/ServletDemo02/aServlet">AServlet</a><br/>
<!--
这种相对路径的方式,先找到项目的根目录然后找到servlet,貌似可以,不过可能出现路径问题,问题会出现在哪呢?
因为相对上一级目录中查找对应的servlet,本次的路径不是固定的,一般使用内部跳转的话,浏览器的地址栏不会发生
变化,就会导致上一级目录发生变化而产生路径问题
http://127.0.0.1:8080/ServletDemo02/toAHtml
http://127.0.0.1:8080/aServlet
-->
<a href="../aServlet">AServlet</a><br/>
<!-- 我们可以使用base属性达到想要的效果,就是在页面设置一个基本地址,然后使用相对路径,设置base的target属性即可
。不过有时候即使设置了base,如果逻辑太过混乱也会出现路径问题,这个时候你就需要多琢磨了 -->
<a href="aServlet">AServlet</a><br/>
</body>
</html>
package com.servlet; import java.io.IOException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class ToAHtml extends HttpServlet {
private static final long serialVersionUID = 1L; public ToAHtml() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("/html/a.html").forward(request, response);
//response.sendRedirect("/html/a.html");
} public void init() throws ServletException {
} }
package com.servlet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class AServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public AServlet() {
super();
} public void destroy() {
super.destroy();
} public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.write("AServlet");
out.close();
}
public void init() throws ServletException {
} }