标签:
HttpServletRequest客户端获取请求,客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中。所以我们能够从对象中获取相应信息
端口
request.getServerPort() ;
获取服务器名称
request.getContextPath();
获取工程名称
request.getContextPath();
获取servlet路径
request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/"));
request.getServerName();
System.out.println("ServerName:"+request.getServerName());
request.getServerPort();
System.out.println("ServerPort:"+request.getServerPort());
request.getContextPath();
System.out.println("ContextPath" + request.getContextPath());
request.getServletPath();
System.out.println("ServletPath" + request.getServletPath());
request.getRequestURI();
System.out.println("RequestURI" + request.getRequestURI());
request.getRequestURL();
System.out.println("RequestURL" + request.getRequestURL());
/*String beanname = requestPath.substring(requestPath.indexOf("iswust/") + 7,
requestPath.indexOf("iswust/") + 11);*/
标签: