当前位置: 代码迷 >> Java Web开发 >> struts2 文件上载有关问题 Can not find a java.io.InputStream with the name [downloadFile]
  详细解决方案

struts2 文件上载有关问题 Can not find a java.io.InputStream with the name [downloadFile]

热度:5492   发布时间:2013-02-25 21:12:52.0
struts2 文件下载问题 Can not find a java.io.InputStream with the name [downloadFile]
严重: Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack. Check the <param name="inputName"> tag specified for this action.

------解决方案--------------------------------------------------------
楼主看看上传到tomcat里面的文件是不是没有了? 楼主如果在eclipse中重启了tomcat 的话,tomcat会自动清空上传到项目下面的文件的,这样你去下载的话肯定是找不到的。
如果你上传到服务器之后,立刻进行下载,是可以下载的,重启服务器再点击下载的话,就会报你那个错了。

------解决方案--------------------------------------------------------
会不会是中文乱码的问题
建议排除上传路径中的中文编码,然后再测试下,是否还会出现类似错误
------解决方案--------------------------------------------------------
public InputStream getDownloadFile()
{
this.setFileName();
return ServletActionContext.getServletContext().getResourceAsStream(
"/"+UploadConfigurationRead.getInstance().getConfigItem("uploadFilePath").trim()+"/" + fileName);
}
改成:

public InputStream getDownloadFile throws FileNotFoundException(){
this.setFileName();
File file = new File("/"+UploadConfigurationRead.getInstance().getConfigItem("uploadFilePath").trim()+"/" + fileName);
InputStream is = new FileInputStream(file);
return is;
}
就行了
  相关解决方案