java类中获取tomcat下的webap路径方法

xiaoxiao2021-02-28  64

1.String url = req.getSession().getServletContext().getRealPath("");输出的是:D:\4_tomcat7\webapps\TradePlatform(我的安装目录下的项目); 2.int ch = url.lastIndexOf("\\");截取最后一个"/"索引 String webapp = url.substring(0, ch);输出:D:\4_tomcat7\webapps  webapps下的其他目录就可以拼接在后面了
转载请注明原文地址: https://www.6miu.com/read-54030.html

最新回复(0)