Struts2中下载项目路径以外的文件报错 Can not find a Java.io.InputStream with the name [downloadFile] in the invoc
来源:互联网 发布:糜烂网络上是什么意思 编辑:程序博客网 时间:2024/05/22 08:00
解决:
1.文件路径不对,根本就没有取到文件。这种情况下,可以将获得InputStream的那条语句放在system.out.println()中输出一下,若为null,那就是路径不对了,或者说得准确些就根本没有找到文件。
2.在action中没有写配置文件中"<param name="inputName">"后面属性的那个get方法.
当以上两种情况都正确的情况下,问题就在这里了:
当采用 return ServletActionContext.getServletContext().getResourceAsStream("...") 这种方法获得输入流的时候,要保证文件位置在 ServletContext 当中,就是说要在当前的应用上下文中,
如果想要获得外部文件譬如 D盘中的某个文件,那么就要自己创建输入流才可以,如:
1. File file = new File("D://spring.doc");
2.
3. InputStream is = new FileInputStream(file);
4.
5. return is;
总结:使用绝对路径。
0 0
- Struts2中下载项目路径以外的文件报错 Can not find a Java.io.InputStream with the name [downloadFile] in the invoc
- 【struts2文件下载】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
- 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.
- (Struts2文件下载)Can not find a java.io.InputStream with the name [inputStream] in the invocation stack
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- struts2下载文件时严重: Can not find a java.io.InputStream with the name [targetFile] in the invocation
- Windows无法删除桌面图标的应对方法
- 服务不支持 chkconfig 的解决方法
- JS单行显示的格式化方法-PhpStorm
- git-基本操作
- linux生成公钥命令
- Struts2中下载项目路径以外的文件报错 Can not find a Java.io.InputStream with the name [downloadFile] in the invoc
- 通过LoCo加速器设置VPN代理上外国网站
- 软件测试
- char、varchar、binary和varbinary的区别与联系
- centos7搭建harbor镜像仓库
- 基于AT91SAM9260的集中抄表系统解决方案
- ZLIB quazip (只能对ZIP进行解压,不能对RAR等其它的压缩文件解压)
- Python笔记-计算密集型(最好用C)、IO密集型(最好用脚本)
- linux使用mysql 在输入了mysql 之后出现 the programe can be found in the following packages