request.getServletContext().getRealPath(“/”) 获取项目所在服务器的全路径,如:D:/Program Files/apache-tomcat-7.0.25/webapps/TestSytem/
request.getServletPath() 获取客户端请求的路径名,如:/object/delObject
request.getServerName() 获取服务器地址,如:localhost
request.getServerPort() 获取服务器端口,如8080
request.getContextPath() 获取项目名称,如:TestSytem
request.getLocalAddr() 获取本地地址,如:127.0.0.1
request.getLocalName() 获取本地IP映射名,如:localhost
request.getLocalPort() 获取本地端口,如:8090
request.getRealPath(“/”) 获取项目所在服务器的全路径,如:D:/Program Files/apache-tomcat-7.0.25/webapps/TestSytem/
request.getRemoteAddr() 获取远程主机地址,如:127.0.0.1
request.getRemoteHost() 获取远程主机,如:127.0.0.1
request.getRemotePort() 获取远程客户端端口,如:3623
request.getRequestedSessionId() 获取会话session的ID,如:823A6BACAC64FB114235CBFE85A46CAA
request.getRequestURI() 获取包含项目名称的请求路径,如:/TestSytem/object/delObject
request.getRequestURL().toString() 获取请求的全路径,如:http://localhost:8090/TestSytem/object/delObject
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10245.html