- public String upload()
- {
- String newFujianName=new Date().getTime()+fujianFileName.substring(fujianFileName.indexOf("."));
- String dstPath = ServletActionContext.getServletContext().getRealPath("upload")+ "\\" + newFujianName;
- keyname=ServletActionContext.getRequest().getParameter("keyname");
- System.out.println("keyname="+keyname);
- File dstFile = new File(dstPath);
- copy(this.getFujian(),dstFile);
- Map request=(Map)ServletActionContext.getContext().get("request");
- request.put("newFujianName", newFujianName);
- request.put("keyname", keyname);
- request.put("oldFujianName", fujianFileName);
- request.put("fujianPath", "/upload"+ "/" + newFujianName);
- return ActionSupport.SUCCESS;
- }
复制代码
里面的
- String dstPath = ServletActionContext.getServletContext().getRealPath("upload")+ "\\" + newFujianName;
复制代码
会报如下错,也就是ServletActionContext.getServletContext().getRealPath("upload")返回的是null
- java.io.FileNotFoundException: null\1399604147459.jpg (系统找不到指定的路径。)
复制代码
求大神教怎么破?
|
|