java struts2 获取项目路径

来源:互联网 发布:lanczos算法解方程 编辑:程序博客网 时间:2024/06/05 18:26
 

java struts2 获取项目路径

 525人阅读 评论(0) 收藏 举报

java:

 

getServletContext().getRealPath("/")

 

struts2:

 

ResourceBundle resource = ResourceBundle.getBundle("voicefileInfo");
                
ActionContext ac = ActionContext.getContext();  
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);  
String LogDir = sc.getRealPath("/").concat(resource.getString("LogDir"));

 

都可利用severlet中的getRealPath("/")方法

原创粉丝点击