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项目部署后的路径中找到特定目录下的特定文件


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM