ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String path = sc.getRealPath("/");
本文介绍了一种在Struts框架中获取文件真实路径的方法。通过ActionContext获取当前Servlet上下文,并利用此上下文得到应用的基础路径。
ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String path = sc.getRealPath("/");
4543
967

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