servlet的请求路径区分

System.out.println("contextPath:"+req.getContextPath());
System.out.println("servletPath:"+req.getServletPath());
System.out.println("requestURI:"+req.getRequestURI());
System.out.println("requestURL:"+req.getRequestURL());

输出结果如下:

contextPath:/test
servletPath:/findEmp
requestURI:/test/findEmp
requestURL:http://localhost:8080/test/findEmp

posted @ 2017-12-16 16:22  森融  阅读(346)  评论(0编辑  收藏  举报