获取Web项目路径

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,Java)