您的位置:首页 > 编程语言 > Java开发

struts2下载文件时严重: Can not find a java.io.InputStream with the name [targetFile] in the invocation

2012-05-01 17:56 951 查看
错在这个方法上:public InputStream getTargetFile(){//对应上边的文件路径,给出它的输入流,对应在配置文件的InputName属性名
return ServletActionContext.getServletContext().getResourceAsStream(downloadFile);
}

strutts.xml在配置时要:<param name="downloadFile">/小莫.jpg</param>   这个与上面的是对应的

控制台打出值为null如下:

null

2012-5-1 17:49:17 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error

严重: Can not find a java.io.InputStream with the name [targetFile] in the invocation
 stack. Check the <param name="inputName"> tag specified for this action.

改正后:

控制台打出值为

信息: Server startup in 16424 ms

java.io.ByteArrayInputStream@c1e4d5

java.io.ByteArrayInputStream@119b1ca

java.io.ByteArrayInputStream@98b13b

下载了三次,自然就有三个咯~~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struts null server c
相关文章推荐