?
<% String path1 = application.getRealPath(request.getRequestURI()); //当前请求的JSP文件的物理路径 String path2 = application.getRealPath("/"); //当前WEB应用的物理路径 String path3 = request.getRequestURI(); StringBuffer path4 = request.getRequestURL(); //getRequestURL()返回的是StringBuffer String virtualPath = request.getServletPath(); //虚拟路径 String realPath = request.getRealPath(virtualPath);//物理路径 %>
?
?
PS:?request.getRequestURI()与request.getRequestURL()的区别
request.getRequestURI()只是显示的是文件的名称 ?//?? /cta/xiahu/xiahu_add.jsp?
request.getRequestURL()显示的全部的URL ? ? ? ? ? // ??http://localhost:7001/cta/xiahu/xiahu_add.jsp
request.getRequestURL()显示的全部的URL ? ? ? ? ? // ??http://localhost:7001/cta/xiahu/xiahu_add.jsp
?