日期:2014-05-19  浏览次数:20590 次

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\bin
2012-5-31 13:32:58 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-5-31 13:32:58 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 560 ms
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-5-31 13:33:10 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31  config=null
2012-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.printl