Struts2文件下载找不到输入流异常】的更多相关文章

先发异常 Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack. Check the <param name="inputName"> tag specified for this action 这个异常是因为在sturts.xml中配置的输入流没有找到或者得不到,或者为Null,总之就是获取不到,原因是因为我在Action中获取流的路径写的不正确,导致…
Struts2极大的简化了文件上传和下载,本文将主要介绍一下Struts2文件下载的实现1.功能主要是,在下载页面点击下载后,则下载相应的文件 2.代码部分jsp页面downloadPage:<body><!--该页面主要就是一个超链接,点击进入DownloadAction,并传递三个参数:原文件的名字,文件类型,显示的下载文件名--><a href="${pageContext.request.contextPath}/download?res=example.p…
<!--struts.xml配置--> <action name="download" class="com.unmi.action.DownloadAction"> <result name="success" type="stream"><!--type 为 stream 应用 StreamResult 处理--> <param name="contentTy…
strut2文件下载三部曲:一个流.两个头信息 说明: ①一个流,在Action中需要一个getInputStream()的方法来获取下载的内容,其中inputStream是默认的,他会指示StreamResult获得inputStream属性的getter方法. ②两个头,一个为ContentType:默认rext/plain文件形式.主要作用是根据下载的文件类型进行文件设置,需要的任何MIME可以在tomcat里面的配置文件中找到 另一个头是ContentDisposition:默认inli…
1). Struts2 中使用 type="stream" 的 result 进行下载 2). 可以为 stream 的 result 设定如下参数 contentType: 结果类型 contentLength: 下载的文件的长度 contentDisposition: 设定 Content-Dispositoin 响应头. 该响应头指定接应是一个文件下载类型, 一般取值为  attachment;filename=document.pdf. inputName: 指定文件输入流的…
使用Struts2做一个简单的文件下载. 首先,导包,写配置文件就不说了. 进入主题. 文件下载操作类:FileDownload.java import java.io.InputStream; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class FileDownload extends ActionSupport{  private…
转自:http://blog.csdn.net/wnczwl369/article/details/7483290 转自:http://hi.baidu.com/c2_sun/item/934a542518c6ecc5a5275aad struts.xml文件配置: <span style="font-size:16px;"><?xml version="1.0" encoding="UTF-8" ?> <!DOCT…
struts.xml文件配置: <span style="font-size:16px;"><?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apac…
成功代码: 前台界面jsp: <a style="text-decoration:none;" href="<%=path %>/main/frontNewsAction_downloadFile.action?fileName=<s:property value="fileTitle"/>">下载</a> Action文件:private String fileName;//get set方法 p…
今天在用struts2就行文件下载时出现如下错误: Servlet.service() for servlet default threw exception java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [imageStream] in the invocation stack. Check the <param name="inputName">…