当前位置: 代码迷 >> J2EE >> Struts2 文件下载 导致的怪异有关问题~【项目不断报错】
  详细解决方案

Struts2 文件下载 导致的怪异有关问题~【项目不断报错】

热度:57   发布时间:2016-04-22 01:14:43.0
Struts2 文件下载 导致的怪异问题~【项目不断报错】
Java code
2012-5-31 13:32:58 org.apache.catalina.core.AprLifecycleListener init信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\Java\jdk1.6.0_20\bin;E:\Tomcat6.0\bin2012-5-31 13:32:58 org.apache.coyote.http11.Http11Protocol init信息: Initializing Coyote HTTP/1.1 on http-80802012-5-31 13:32:58 org.apache.catalina.startup.Catalina load信息: Initialization processed in 560 ms信息: JK: ajp13 listening on /0.0.0.0:80092012-5-31 13:33:10 org.apache.jk.server.JkMain start信息: Jk running ID=0 time=0/31  config=null2012-5-31 13:33:10 org.apache.catalina.startup.Catalina start信息: Server startup in 12239 ms

上面的是启动信息,删掉了部分,因为信息太多。。。启动不报错,
启动完成之后,我并没有运行项目,关于项目的任何页面都没有打开
但是,奇怪的是,后台一直输出错误信息:
Java code
null检查action中文件下载路径是否正确.2012-5-31 13:35:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.null检查action中文件下载路径是否正确.2012-5-31 13:35:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.2012-5-31 13:35:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.null检查action中文件下载路径是否正确.null检查action中文件下载路径是否正确.2012-5-31 13:35:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.null检查action中文件下载路径是否正确.2012-5-31 13:35:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.null检查action中文件下载路径是否正确.2012-5-31 13:35:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: 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.



Action如下:
Java code
public class DownloadActionTrue extends ActionSupport {    /**     * generate serialVersionUID     */    private static final long serialVersionUID = -1502162994976647682L;    // 下载文件原始存放路径    private final static String DOWNLOADFILEPATH = "/upload/";    // 文件名参数变量    private String fileName;    public String getFileName()  {        return fileName;    }    public void setFileName(String fileName) throws UnsupportedEncodingException {        this.fileName = fileName;    }    @Override    public String execute() throws Exception {        return SUCCESS;    }    // 从下载文件原始存放路径读取得到文件输出流    public InputStream getInputStream() throws Exception {        String realPath = DOWNLOADFILEPATH + fileName;        InputStream inputStream = ServletActionContext.getServletContext()                .getResourceAsStream(realPath);        System.out.println(inputStream);        if (null == inputStream) {            System.out.println("检查action中文件下载路径是否正确.");        }        return inputStream;    }    // 如果下载文件名为中文,进行字符编码转换    public String getDownloadFileName() {        String downFileName = fileName;        try {            downFileName = new String(downFileName.getBytes("iso-8859-1"));            System.out.println(downFileName);        } catch (UnsupportedEncodingException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }        return downFileName;    }    }
  相关解决方案