本文轉載於:https://www.cnblogs.com/meng2/p/7906985.html
Request對象通過以下方法來獲取請求路徑。
(1)String getServerName():獲取服務器名:localhost
(2)String getServerPort():獲取服務器端口號:8080
(3)String getContextPath():獲取項目名:Test
(4)String getServletPath():獲取Servlet路徑:/login
(5)String getQueryString():獲取參數部門,即問號后面的部分:username=zhangsan
(6)String getRequestURL():獲取請求URL