struts2如何实现文件的下载 30
在文件上传的时,直接上传到了tomcat工程下面,但是在实现文件下载时,这样获取路径:ServletContextservletContext=ServletAction...
在文件上传的时,直接上传到了tomcat 工程下面,
但是在实现文件下载时,这样获取路径:ServletContext servletContext=ServletActionContext.getServletContext(); String fileName=servletContext.getRealPath("/12.jpg");
报错却是java.lang.IllegalArgumentException: 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. org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237) org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)查看源码:
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);
}
应该是路径出错了!但是不知道怎么改!求助! 展开
但是在实现文件下载时,这样获取路径:ServletContext servletContext=ServletActionContext.getServletContext(); String fileName=servletContext.getRealPath("/12.jpg");
报错却是java.lang.IllegalArgumentException: 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. org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237) org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)查看源码:
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);
}
应该是路径出错了!但是不知道怎么改!求助! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询