Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
来源:互联网 发布:中国有多少混血儿知乎 编辑:程序博客网 时间:2024/06/05 03:29
具体出现异常为:
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.
据说可能是以下两种方法导致:
<action name="Affix_download" class="org.xidian.team8.document.DownloadAction">
<result name="success" type="stream">
<param name="contentType">application/octet-stream;charset=GBK</param>
<param name="contentDisposition">attachment;filename="${filename}"</param>
<param name="inputName">downloadFile</param>
</result>
</action>
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class DownloadAction extends ActionSupport {
private static final long serialVersionUID = 1L;
// 下载文件原始存放路径
private final static String DOWNLOADFILEPATH = "/upload/";
private String filenameInCN;
private String filename;
@Override
public String execute() throws Exception {
//System.out.println("下载文件:" + filenameInCN);
return SUCCESS;
}
public String getFilenameInCN() {
return filenameInCN;
}
public void setFilenameInCN(String filenameInCN) {
try {
this.filename = new String(filenameInCN.getBytes("ISO-8859-1"), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
}
public InputStream getDownloadFile() throws Exception {
//找到相关文件返回流
String realPath = DOWNLOADFILEPATH+filename; //错误路径(因为空格的问题)
System.out.println("上传文件:" + filenameInCN);
System.out.println("错误路径:" + realPath );
String realPath1=realPath.replaceAll(" ", ""); //正确路径(过滤掉错误路径中的空格)
System.out.println("正确路径:" + realPath1 );
return ServletActionContext.getServletContext().getResourceAsStream(realPath1);
}
public String getFilename() {
try {
return new String(this.filename.getBytes(), "ISO8859-1");
} catch (UnsupportedEncodingException e) {
return "获取文件名出现了错误!";
}
}
public void setFilename(String filename) {
this.filename = filename;
}
}
- 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 [inputStream] in the invocation stack问题解决
- 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 [downloadFile] 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 [] 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.
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <p
- 文件下载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 [inputStream] in the invocation stack
- (文件下载)Can not find a java.io.InputStream with the name [inputStream] in the invocation stack
- [29期] [Linux常用]Shell 命令和语句
- [27期] 关于项目的一些体会
- [29期] 随便说说我的学习感受
- 关于在页面中针对不同版本的IE浏览器实现不同的JS或者CSS样式
- [29期] HTML代码总结(第一弹)
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- [29期] 关于HTML学习以及标签记忆的一些感受
- 那些年,mfc开发中要注意的一些小细节
- [28期] 侯永伟职业规划
- [27期] 电子商城项目总结
- Unity粒子的相关属性介绍
- [29期] 心态杂谈,从跑步到走路
- [27期] 第二个项目文档和数据库设计
- [27期] 第二个项目给我增加的感觉