改变世界的是这样一群人,他们寻找梦想中的乐园,当他们找不到时,他们亲手创造了它

java项目部署后的文件路径获取

        //eclipse部署工程
        String path = request.getServletContext().getRealPath(
                File.separator+ "WEB-INF" + File.separator
            + "platform"+ File.separator
            +"configuration"+ File.separator
            +"services");
        //tomcat部署工程
        if(path==null){
            String tomcatBinPath = System.getProperty("user.dir");
            String tomcatRootPath = tomcatBinPath.substring(0, tomcatBinPath.lastIndexOf(File.separator));
            path = tomcatRootPath+File.separator+"webapps"+File.separator+"jointos"+File.separator+ "WEB-INF" + File.separator + "platform"+ File.separator
            +"configuration"+ File.separator+"services";
        }

以上方式可以获取到java项目部署后的路径中找到特定目录下的特定文件

posted @ 2017-08-15 14:11  水狼一族  阅读(2899)  评论(0编辑  收藏  举报
改变世界的是这样一群人,他们寻找梦想中的乐园,当他们找不到时,他们亲手创造了它