凡是要表示web资源的地址,比如浏览器地址栏中,都是 /
凡是要表示硬盘地址, 都是 \
public class ServletDemo1 extends HttpServlet { //实际开发过程中的地址写法
//如果地址是给服务器用的, / 代表当前web应用
//如果地址是给客户端用的, / 代表整个网站(一个网站可以有多个web应用)
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { //情况有以下几种 //1.转发(服务器)
request.getRequestDispatcher("/index.jsp").forward(request, response); //2. 重定向 (客户端)
response.sendRedirect("/day06/index.jsp"); //3. 获取地址(服务器)
this.getServletContext().getRealPath("index.jsp"); //4. 获取请求资源(服务器)
this.getServletContext().getResource("index.jsp"); //JSP上的两种 (客户端)
/*<a href="/day06/index.jsp">点击</a> <form action="/day06/index.jsp"></form>*/ }
}