struts2獲取項目根目錄的方法
在開發Struts項目時,我們有時需要獲取項目的根目錄,可以使用下面的方法獲取:
ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String temp = ServletActionContext.getRequest().getRealPath("/");
評論內容只代表網友觀點,與本站立場無關!
評論摘要(共 0 條,得分 0 分,平均 0 分)
查看完整評論