路徑資訊
http://localhost:8080/myWebApp/PathServlet/.txt?param1=value1¶m2=value2
req.getScheme()
http
req.getServerName()
localhost
req.getServerPort()
8080
req.getContextPath()
即環境路徑,/myWebApp
req.getServletPath()
即 Servlet 路徑,/Path/Servlet
req.getPathInfo()
即額外路徑,/1.txt
req.getRequestURI()
即環境路徑 + Servlet 路徑 + 額外路徑,/myWebApp/PathServlet/.txt
req.getRequestURL()
即完整路徑,http://localhost:8080/myWebApp/PathServlet/.txt
req.getQueryString()
即查詢參數 QueryString
Last updated
Was this helpful?