首页 > 开发 > JSP > 正文

struts2获取项目根目录的方法

2023-05-01 14:14:49
字体:
来源:转载
供稿:网友

 在开发Struts项目时,我们有时需要获取项目的根目录,可以使用下面的方法获取:

ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String temp = ServletActionContext.getRequest().getRealPath("/");

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表