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下的其他目录就可以拼接在后面了
2.int ch = url.lastIndexOf("\\");截取最后一个"/"索引
String webapp = url.substring(0, ch);输出:D:\4_tomcat7\webapps
webapps下的其他目录就可以拼接在后面了