ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String path = sc.getRealPath("/");
System.out.println("new path := " + path);Struts2获取当前项目的根目录
最新推荐文章于 2021-08-12 03:57:25 发布
本文介绍了如何使用Struts框架中的ActionContext与ServletActionContext来获取项目的实际路径。通过ActionContext获取当前上下文,并通过该上下文获取ServletContext,进而得到项目的根路径。
252

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



