1 2 3 4 5 6 7 8 |
//HttpServletRequest 对象通过以下方法来获取请求路径,如下所示: String serverName = request.getServerName();//获取服务器名,127.0.0.1; int serverPort = request.getServerPort();//获取服务器端口号,8083; String contextPath = request.getContextPath();//获取项目名,/Aop; String ServletPath=request.getServletPath();//获取Servlet路径,/getUserDetails/45; String QueryString=request.getQueryString();//获取参数部分,即问号后面的部分:username=zhangsan StringBuffer RequestURL=request.getRequestURL();//获取请求URL,等于不包含参数的整个请求路径:http://localhost:8083/Aop/getUserDetails/45 String RemoteAddr=request.getRemoteAddr();//获取服务器的IP,如localhost对应ip为127.0. |
from:https://www.cnblogs.com/zhoading/p/13954370.html