错在这个方法上: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
下载了三次,自然就有三个咯~~~