论坛首页 Java企业应用论坛

ssh下载问题,下面是代码

浏览 2833 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2015-08-27  
jsp:<s:a href="down.action?fileName=%{#ds.datumname}">下载</s:a>

action:public class DownAction extends ActionSupport{

/**
*
*/
private static final long serialVersionUID = 1L;
private String path=ServletActionContext.getServletContext().getRealPath("upload")+"\\";
private String fileName;


public String getFileName() throws UnsupportedEncodingException {
return new String(fileName.getBytes(), "ISO-8859-1");
}


public void setFileName(String fileName) {
this.fileName = fileName;
}
public InputStream getInputStream() throws FileNotFoundException{
return new FileInputStream(new File(path, fileName));

}

public String execute(){
return "success";
}

}
struts.xml
<action name="down" class="com.news_date.control.DownAction">
<result name="success" type="stream">
<param name="inputName">inputStream</param>
<param name="contentDispostion">attachment;filename="${fileName}"</param>
</result>
</action>

执行报错: Struts has detected an unhandled exception:
Messages:
Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the tag specified for this action.
File: org/apache/struts2/dispatcher/StreamResult.java
Line number: 237
这是啥问题啊,求指教.新手不容易啊.总是受伤害啊
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics