ITeye博客

从request获取各种路径总结

and4walker · 2007-12-19 14:50 · Struts · Web · Markdown

从request获取各种路径总结 request.getRealPath("url");//虚拟目录映射为实际目录 request.getRealPath("./");//网页所在的目录 request.getRealPath("../");//网页所在目录的上一层目录

request.getContextPath();//应用的web目录的名称 如http://localhost:7001/bookStore/
/bookStore/ => [contextPath] (request.getContextPath())

获取Web项目的全路径 String strDirPath = request.getSession().getServletContext().getRealPath("/");

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。