如果你使用的是你自己下载的tomcat,那么无论做什么都无法把上传的文件保存在项目中。
String classPath = this.getClass().getClassLoader().getResource("/").getPath(); String path=request.getSession().getServletContext().getRealPath("/upload/"); String paths=System.getProperty("user.dir");
这三个都不可以,指向的都是你自己下载的tomcat里面的webapp文件夹而不是你的idea项目
改这个output directory也没什么用
解决办法:老老实实用maven-tomcat插件吧。