Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <p

关于stuts的下载文件问题
具体异常:
 Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action. 就是这个问题,从一点多纠结了,几个小时,查了好多资料,也没查到。请看:事情是这样的、、、、、、、、、、、
1文件路径不对,根本就没有取到文件。这种情况下,可以将获得InputStream的那条语句放在system.out.println()中输出一下,若为null,那就是路径不对了,或者说得准确些就根本没有找到文件。
2.在action中没有写配置文件中"<param name="inputName">"后面属性的那个get方法.

3.而当属性写错时,也会出现这样情况,<param name="inputName">inputStream</param>和private InputStream inputStream;
必须要一致
	public String getContentType() {
		return contentType;
	}
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	public long getContentLength() {
		return contentLength;
	}
	public void setContentLength(long contentLength) {
		this.contentLength = contentLength;
	}
	public String getContentDispostion() {
		return contentDispostion;
	}
	public void setContentDispostion(String contentDispostion) {
		this.contentDispostion = contentDispostion;
	}<pre name="code" class="java">
public InputStream getInputstraam() {return inputStream;}
 
  


而我的配置文件是
<action name="testDowload" 
			class="com.zhu.cn.dowload.DowloadAction">
			<!-- 可以实现上传与下载功能 -->
			     <result name="success" type="stream">
                <span style="background-color: rgb(255, 0, 0);"> <param name="inputName">inputStream</param></span>
                 <param name="contentType">application/octet-stream</param>                 <param name="contentDisposition">filename="main111222.css"</param>
                <param name="bufferSize">2048</param>
             </result>
		
		</action>	
就是这个问题,就因为我的粗心,造成的。而
<span style="background-color: rgb(255, 0, 0);"><span style="font-size:18px;">inputStream 必须</span><span style="font-size: 18px;">和</span></span><strong style="font-size: 12px; font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"><span style="font-size:18px;"></span></strong><div style="display: inline !important;"><pre name="code" class="html" style="display: inline !important;"><span style="background-color: rgb(255, 0, 0);"></span><pre name="code" class="java" style="display: inline !important;"><span style="background-color: rgb(255, 0, 0);">Inputstraam一致  </span>
 
 
 
 
<span style="font-size:18px;">	public String execute() throws Exception {
		// TODO Auto-generated method stub
		//ServletContext  servletcontent=ServletActionContext.getServletContext();
	  //  String dir=servletcontent.getRealPath("/file/"+pptFileName);			
		contentDisposition="attachment;filename=bb.html";
		ServletContext servletcont=ServletActionContext.getServletContext();
	     System.out.println("路径"+servletcont);
	     String filename=servletcont.getRealPath("/file/bb.html");
	     System.out.println(filename);
	     //filename=new String(filename.getBytes("UTF-8"),"ISO8859-1");
	    // System.out.println(filename);
		inputStream=new FileInputStream(filename);
		System.out.println(inputStream);
		if(inputStream==null){
			System.out.println("空值");
		}
		contentLength = inputStream.available();
		System.out.println(contentLength);
		return SUCCESS;
	}</span>

具体的配置都在这里,这样就可以进行文件的下载,jspsmart .jar可以进行文件下载,现在也可以用stuts实现文件传输。另外写代码一定要规范,否则,一点小熊错,可能导致你全盘皆输,今天就是血的教训。。。。。。。。。。。。。。。。。。。。。。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值