A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© ℡Bruce 初级黑马   /  2014-5-9 10:59  /  907 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. public String upload()
  2.         {
  3.                 String newFujianName=new Date().getTime()+fujianFileName.substring(fujianFileName.indexOf("."));
  4.                 String dstPath = ServletActionContext.getServletContext().getRealPath("upload")+ "\\" + newFujianName;
  5.                  keyname=ServletActionContext.getRequest().getParameter("keyname");
  6.                 System.out.println("keyname="+keyname);
  7.                 File dstFile = new File(dstPath);
  8.                 copy(this.getFujian(),dstFile);
  9.                 Map request=(Map)ServletActionContext.getContext().get("request");
  10.                 request.put("newFujianName", newFujianName);
  11.                 request.put("keyname", keyname);
  12.                 request.put("oldFujianName", fujianFileName);
  13.                 request.put("fujianPath", "/upload"+ "/" + newFujianName);
  14.                 return ActionSupport.SUCCESS;
  15.         }
复制代码


里面的
  1. String dstPath = ServletActionContext.getServletContext().getRealPath("upload")+ "\\" + newFujianName;
复制代码

会报如下错,也就是ServletActionContext.getServletContext().getRealPath("upload")返回的是null
  1. java.io.FileNotFoundException: null\1399604147459.jpg (系统找不到指定的路径。)
复制代码

求大神教怎么破?

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马