您的位置:首页 > 编程语言 > Java开发

获取Web项目路径

2016-04-07 18:37 351 查看
public class ApplicationListener implements ServletContextListener {
public static String WEB_PATH = null;
public void contextInitialized(ServletContextEvent sce) {
String webPath = sce.getServletContext().getRealPath("/");
ApplicationListener.WEB_PATH = webPath;
System.setProperty("PROJECT_LOG", webPath);
System.setProperty("WEB_PATH", webPath);
LogUtil.init(webPath + "/config/log4j.xml");
}

public void contextDestroyed(ServletContextEvent sce) {

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  web java