现在的位置: 首页 > 综合 > 正文

在Struts2的Action中,得到当前应用的物理路径

2014年11月14日 ⁄ 综合 ⁄ 共 357字 ⁄ 字号 评论关闭

ServletContext servletContext = (ServletContext)ActionContext.getContext().get(ServletActionContext.SERVLET_CONTEXT);

String rootPath = servletContext.getRealPath("/");

-------------------------------------------------

//方法二:

String rootPath = ServletActionContext.getServletContext().getRealPath("/"); 

自:http://georgeinfo.blog.163.com/blog/static/1636833412011235525318/

抱歉!评论已关闭.