从request获取各种路径总结:
request.getRealPath("url");//虚拟目录映射为实际目录
request.getRealPath("./");//网页所在的目录
request.getRealPath("../");//网页所在目录的上一层目录
假定你的web application(web应用)名称为news,你的浏览器中输入请求路径:
http://localhost:8080/uploading/load.jsp
request.getContextPath() => /uploading
request.getServletPath() => /load.jsp
request.getRequestURL() => http://localhost:8080/uploading/load.jsp
request.getRealPath("/") => F:\learn\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\uploading\
本文详细介绍了如何使用Java Servlet API中的request对象来获取Web应用程序的各种路径信息,包括上下文路径、servlet路径、完整的请求URL及文件的真实路径。
125

被折叠的 条评论
为什么被折叠?



