Request 获取请求的 URL
程序员文章站
2022-03-10 09:46:49
...
Request 获取请求的 URL
端口:8080
request.getServerPort();
服务器:localhost
request.getServerName();
项目名:wechat-ssm
request.getContextPath();
ServletPath: servlet/demoServlet
request.getServletPath();
RequestURI: wechat-ssm/servlet/demoServlet
request.getRequestURI();
整个请求路径:http://localhost:8080/wechat-ssm/servlet/demoServlet
request.getRequestURI();
项目的路径:D:\Tomcat7.0\webapps\wechat-ssm
request.getSession().getServletContext().getRealPath("");