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

Struts2 上载有关问题

2012-12-17 
Struts2 下载问题?报错: Can not find a java.io.InputStream with the name 。。。。。。。。主要代码:public Inp

Struts2 下载问题?
报错:
 Can not find a java.io.InputStream with the name 
。。。。。。。。

主要代码:

public InputStream getInputStream() throws Exception {


 return ServletActionContext.getServletContext().getResourceAsStream("/WEB-INF/" + this.fileName);
    
  
  
}



<struts>
     <package name="default" extends="struts-default">
     
     <action name="download" class="com.DownloadAction">

      <result type="stream">
      <!-- 
        <param name="directory">D:/download/</param> -->
<param name="contentType">application/octet-stream</param>

<param name="inputName">inputStream</param>

<param name="contentDisposition">attachment;filename="${fileName}"</param>

<param name="bufferSize">4096</param>

 </result>

   </action>

访问路径。。
http://192.168.0.52:8080/XT/download.action?filename=qq.txt

有关struts2下载的,指导下
[最优解释]

引用:
报错:
 Can not find a java.io.InputStream with the name 
。。。。。。。。

主要代码:

public InputStream getInputStream() throws Exception {


 return ServletActionContext.getServletContext().……


灰常有可能是路径问题哦亲!!!
[其他解释]
好复杂呀,
下载就一个response就够了,
如果是非文本文件,response都不需要,一个链接搞定!
[其他解释]
qq.txt
你看看你的/WEB-INF/路径下有这个文件吗?

--------------
你的qq.txt路径是?

热点排行