获取webxiangmudeju项目的绝对路径

request.getSession().getServletContext().getRealPath(“”)
传入的参数前后一定要加 / 才能保证传入到文件目录下
例如:request.getSession().getServletContext().getRealPath(“/images/”)
输出为E:\software\apache-tomcat-8.0.21\wtpwebapps\SsmDemo\ ssmdemo为项目名字
request.getRealPath已经不推荐使用了

猜你喜欢

转载自blog.csdn.net/peanutwzk/article/details/80977748