本文轉載自:http://blog.csdn.net/u012515904/article/details/45577919
重定向:response.sendRedirect() 可以使用相對路徑和絕對路徑
當浏覽器想伺服器發起了一個http請求時,如:http:localhost:8080/myapp/user/Test1
相對路徑:response.sendRedirect("Login") 容器相對于原來請求URL的目錄加參數來生成完整的URL—http:localhost:8080/myapp/user/Login
絕對路徑 :response.sendRedirect("/Login") 容器相對于Web應用本身加參數建立完整的URL—http:localhost:8080/Login
轉發:request.getRequestDispatcher() 也可以使用相對路徑和絕對路徑
相對路徑:request.getRequestDispatcher("Login") 容器相對于原來請求URL的目錄加參數來生成完整的URL—http:localhost:8080/myapp/user/Login
絕對路徑 :request.getRequestDispatcher("/Login") 容器相對于目前的Web應用本身加參數建立完整的URL—http:localhost:8080/myapp/Login
标簽:http,重定向,URL,myapp,轉發,8080,Login,localhost,javaweb
來源: https://blog.csdn.net/dingding_p/article/details/94611416