struts2中文件上传路径

来源:互联网 发布:高仿女包淘宝店 编辑:程序博客网 时间:2024/05/16 05:22
String directory = "/upload";String targetDirectory = ServletActionContext.getServletContext().getRealPath(directory);

targetDirectory 路径是指eclipse 工作目录下

          *\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps\Exercise\upload

若是发现路径中包含了web服务器的路径,那你就要采用截串的办法,将路径定位到相对路径下。