struts2檔案下載出現Can not find a java.io.InputStream with the name的錯誤

來源:互聯網
上載者:User

 

struts2檔案下載出現Can not find a java.io.InputStream with the name的錯誤
JavaApacheServlet

    今天在用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 exceptionjava.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.             }  
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.