JAVA 得到上下文绝对路径
2009-01-22 08:36
295 查看
]/* 第一种:在 Struts2 当中,Struts1同样也可通过这种形式获取: */ /* 获取 request 对象 */ HttpServletRequest request = ServletActionContext.getRequest(); /* 得到当前上下文绝对路径以保存图片 */ String contextPath = request.getSession().getServletContext().getRealPath("//"); /* 第二种:在 Filter 当中: */ public void init(FilterConfig config) throws ServletException { /* 可将此参数放入到 Session 可供全局使用 */ String contextPath = config.getServletContext().getRealPath("//"); } /* 第三种 */ String contextPath = request.getScheme()+"://"+request.getServerName() +":"+request.getServerPort()+request.getContextPath()+"/";
相关文章推荐
- Java得到上下文的绝对路径
- JAVA 得到上下文绝对路径
- java的绝对路径,相对路径,上下文
- JavaWeb(EE)相对路径_绝对路径详解与得到相关路径
- java ssh中得到上下文路径
- 【java编程】IO流之得到指定目录下.java文件的绝对路径
- java的绝对路径,相对路径,上下文
- java中得到classpath和当前类的绝对路径的一些方法(路径中的%20"进行替换空格)
- 【转】java中相对路径,绝对路径问题总结
- java 路径访问全接触 url相对路径、绝对路径
- java获得项目绝对路径
- java.io.File中的绝对路径和相对路径.
- java中相对路径,绝对路径问题总结
- C#之WinForm基础 得到文件对话框(一次只能打开多个文件)打开文件们的绝对路径
- JAVA IO - 文件绝对路径
- Java爬虫的相对路径转绝对路径
- java路径相关(相对路径,绝对路径,抽象路径)
- Java获得Eclipse中的src绝对路径
- Java 代码 datagrid导出表格为excel的路径为绝对路径(本地电脑)
- [java 基础]相对路径,绝对路径以及盘符(硬盘)路径