struts2文件下载出现Can not find a java.io.InputStream with the name的错误

 

struts2文件下载出现Can not find a java.io.InputStream with the name的错误

    今天在用struts2就行文件下载时出现如下错误:

 

Java代码
  1. Servlet.service() for servlet default threw exception   
  2. java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [imageStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.   
  3.     at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:189)   
  4.     at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)   
  5.     at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)   
  6.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)   
  7.     at com.best.top.validate.TopInterceptor.intercept(TopInterceptor.java:47)   
  8.     at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)   
  9.     at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)   
  10.     at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)   
  11.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)   
  12.     at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)   
  13.     at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)   
  14.     at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)  
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"> tag specified for this action.
	at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:189)
	at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
	at com.best.top.validate.TopInterceptor.intercept(TopInterceptor.java:47)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
	at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
	at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
	at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

 

     说实话这个提示真有误导人的嫌疑,刚开始还以为是名称不对,估计一般人看到这个提示都这样想。然后查看StreamResult的源代码才发现是因为InputStream为null的缘故,汗一个。看下源码:

 

Java代码
  1. if (inputStream == null) {   
  2.                 // Find the inputstream from the invocation variable stack   
  3.                 inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation));   
  4.             }   
  5.   
  6.             if (inputStream == null) {   
  7.                 String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " +   
  8.                     "Check the <param name=\"inputName\"> tag specified for this action.");   
  9.                 LOG.error(msg);   
  10.                 throw new IllegalArgumentException(msg);   
  11.             }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值