Can not find a java.io.InputStream with the name [downloadFile]
来源:互联网 发布:什么是数据切片 编辑:程序博客网 时间:2024/06/03 16:37
转载: http://scorpiomiracle.iteye.com/blog/583387
tomcat报错如下:
严重: 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.出现这种错误一般只有两种可能:
1.文件路径不对,根本就没有取到文件,这种情况下,可以将获得InputStream的那条语句放在system.out.println()中输出一下,若为null,那就是路径不对了,或者说得准确些,就是根本没有找到文件。
2.在action中没有写对应于 配置文件中“ <param name="inputName"> ”后面属性的get方法,如本例就应该写public InputStream getDownloadFile()方法
附:
我也采用了视频和网络上用的最多的方法来返回输入流,如下:
- return ServletActionContext.getServletContext().getResourceAsStream("……");
但是不管怎么弄,都是报如上错误。在一博客上看到,“对ServletContext的getResourceAsStream方法认识有误,该方法不是从本地路径取文件,而是tomcat的工程路径下取文件流”,如“/WEB-INF/download/file.*”。此刻才恍然大悟,我要下载的文件就是位于其他路径,之前分析报错原因总认为肯定是配置的错误。然后,照其所说,一试,果然控制台输出为null,怪不得,于是改为如下方式获得文件流。
- File fileDes = new File(path);//path是要下载文件所在的路径,可以写成任意本地路径
- InputStream is = new FileInputStream(fileDes);
- return is;
0 0
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack.
- java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [downloadFile]
- 【struts2文件下载】Can not find a java.io.InputStream with the name [downloadFile]...
- Can not find a java.io.InputStream with the name [downloadFile]
- Struts2 下载 Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack
- Struts2中下载项目路径以外的文件报错 Can not find a Java.io.InputStream with the name [downloadFile] in the invoc
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack问题解决
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack
- Can not find a java.io.InputStream with the name [inputStream] in the invocation
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack
- Can not find a java.io.InputStream with the name [] in the invocation stack 解决办法
- Can not find a java.io.InputStream with the name [...] in the invocation stack. ...
- Can not find a java.io.InputStream with the name [targetFile] in the invocation stack.
- mysql 入门级命令
- Android 手电筒设计
- 修改php默认的FastCGI模式为ISAPI模式的方法
- 单例模式
- day6面向对象2
- Can not find a java.io.InputStream with the name [downloadFile]
- 使用Memory Analyzer tool(MAT)分析内存泄漏(一)
- iOS 数据持久化四-SQLite3
- cocos2dx 常见的49中动作详解
- Maven是一个Java工具
- 原谅我不是一个阳光的男孩
- DSP的EMIF接口通信FPGA
- 多少定位d 问答额
- yii rules规则中 unique的验证