请求页面:
<a href="downloadTemplateAffix.action" class="nav">${templateWordAddress}</a>
struts配置:
<action name="downloadTemplateAffix" class="contcontractTemplateAction">
<result type="stream">
<param name="contentType">application/vnd.ms-word</param>
//inputName要与action中方法对应
<param name="inputName">templateAffix</param>
<param name="bufferSize">10000</param>
//此处必须有,fileName显示要下载的附件的名字
<param name="contentDisposition">attachment;fileName="abc.docx"</param>
</result>
</action>
action代码
public InputStream getTemplateAffix() throws FileNotFoundException{
//此处地址为相对根路径的地址,且要有“/”
return ServletActionContext.getServletContext().getResourceAsStream("/templateFile/"+"标准测试模板322.docx");
}
若出现
Can not find a java.io.InputStream with the name [] in the invocation stack,Check the <param name="inputName"> tag specified for this action.
问题,请参考我的另一篇转载的博文。
欢迎加入我的QQ交流群425783133