web工程中各类地址,最好以/开头开始前先想好:地址是给谁用的
- 服务器:/ == web应用
- 浏览器: / == 网站
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1,地址是给服务器用的 request.getRequestDispatcher("/foot.jsp").forward(request,response); //2,地址是给浏览器用的 response.sendRedirect("/day06/foot.jsp"); //3,服务器 this.getServletContext().getRealPath("/foot.jsp"); //4,服务器 this.getServletContext().getResourceAsStream("/public/head.jsp"); //5,给浏览器 /* <a href="/day06/foot.jsp">xxxxx</a> <form action="/day06/head.jsp"></form> */ }