The error "can not find a java. Io. inputstream with the name" occurs during struts2 file download.
Javaapacheservlet
The following error occurs when you download a file using struts2 today:
Java code
- 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.strutsresultsuppsupp.exe cute (strutsresultsupport. Java: 178)
- At com.opensymphony.xwork2.defaactionactioninvocation.exe cuteresult (defaultactioninvocation. Java: 348)
- At com. opensymphony. xwork2.defaactionactioninvocation. Invoke (defaactionactioninvocation. 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.defaactionactioninvocation. Invoke (defaactionactioninvocation. Java: 221)
- At org.apache.struts2.impl.strutsactionproxy.exe cute (strutsactionproxy. Java: 50)
- At org. Apache. struts2.dispatcher. Dispatcher. serviceaction (dispatcher. Java: 504)
- 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.exe cute (strutsresultsupport. java: 178) at com.opensymphony.xwork2.defaactionactioninvocation.exe cuteresult (defaultactioninvocation. java: 348) at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 253) at com. best. top. validate. topinterceptor. intercept (topinterceptor. java: 47) at com. opensymphony. xwork2.defaactionactioninvocation $2. doprofiling (defaactionactioninvocation. java: 224) at com. opensymphony. xwork2.defaactionactioninvocation $2. doprofiling (defaactionactioninvocation. java: 223) at com. opensymphony. xwork2.util. profiling. utiltimerstack. profile (utiltimerstack. java: 455) at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221) at org.apache.struts2.impl.strutsactionproxy.exe cute (strutsactionproxy. java: 50) at Org. apache. struts2.dispatcher. dispatcher. serviceaction (dispatcher. java: 504) at Org. apache. struts2.dispatcher. filterdispatcher. dofilter (filterdispatcher. java: 419)
To tell the truth, this prompt is really misleading. At first, I thought it was a wrong name. It is estimated that most people think like this when they see this prompt. Then, check the source code of streamresult to find that the inputstream is null, and sweat. Check the source code:
Java code
- If (inputstream = NULL ){
- // Find the inputstream from the invocation variable Stack
- Inputstream = (inputstream) Invocation. getstack (). findvalue (conditionalparse (inputname, invocation ));
- }
- If (inputstream = NULL ){
- String MSG = ("can not find a java. Io. inputstream with the name [" + inputname + "] in the invocation stack." +
- "Check the <Param name = \" inputname \ "> tag specified for this action .");
- Log. Error (MSG );
- Throw new illegalargumentexception (MSG );
- }