读书人

Struts2 上载有关问题

发布时间: 2012-12-17 09:31:40 作者: rapoo

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路径是?

读书人网 >Java Web开发

热点推荐