首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

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

2013-11-14 
struts2 文件下载问题 Can not find a java.io.InputStream with the name [downloadFile]严重: Can not f

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;
}
就行了

热点排行