我在上次的时候如果上传类型和大小没有问题可以上传成功,但是如果上传了一个部分允许的类型或超出大小范围后失败,而且之后再上传正常的文件也上传不了,也不报错,这是为什么呢org.apache.struts2.dispatcher.ActionContextCleanUp这个也设了,加了日志也没有错误,应该不是ACTION里面的代码问题,是不是需要什么配置呢?

解决方案 »

  1.   

    应该不会的!
    请将stacktrace贴出
      

  2.   

    action根本就不报错
    这是ACTION:
    try {
    String subfix = this.fileName.substring(this.fileName
    .lastIndexOf(".")); if (subfix.equals(".doc") || subfix.equals(".docx")) {
    this.savePath = this.savePath + "/" + "doc";
    } else if (subfix.equals(".bmp")) {
    this.savePath = this.savePath + "/" + "bmp";
    } else if (subfix.equals(".jpg") || subfix.equals(".jpeg")) {
    this.savePath = this.savePath + "/" + "jpg";
    } else if (subfix.equals(".gif")) {
    this.savePath = this.savePath + "/" + "gif";
    } else if (subfix.equals(".exe")) {
    this.savePath = this.savePath + "/" + "exe";
    }
    desFilename = ServletActionContext.getServletContext().getRealPath(
    this.savePath)
    + "/"
    + System.currentTimeMillis()
    + this.saveFilename
    + subfix;
    File destFile = new File(desFilename); BufferedInputStream in = new BufferedInputStream(
    new FileInputStream(this.uFile), this.UPLOAD_BUFFER_SIZE);
    BufferedOutputStream out = new BufferedOutputStream(
    new FileOutputStream(destFile), this.UPLOAD_BUFFER_SIZE); byte[] data = new byte[this.UPLOAD_BUFFER_SIZE]; int len; while ((len = in.read(data)) > 0) { out.write(data, 0, len);
    }
    in.close();
    out.close();
    desFilename = this.savePath + "/" + System.currentTimeMillis()
    + this.saveFilename + subfix;
    desFilename = desFilename.substring(1);
    return SUCCESS;
    } catch (Exception ex) {
    log.error("失败", ex);
    return ERROR;
    }
    struts.xml
    <!-- 上传文件 -->
    <action name="fupload" class="fileAction" method="uploadFile">
    <param name="savePath">/upload</param>
    <interceptor-ref name="fileUpload">
    <param name="allowedTypes">image/bmp,image/jpg,image/pjpeg,image/jpeg,image/gif,application/msword</param>
    <param name="maximumSize">10240000</param>
    </interceptor-ref>
    <!-- 必须加这个拦截器 -->
    <interceptor-ref name="defaultStack"></interceptor-ref>
    <result name="success">
    /UI/UploadFile/uploadSuccess.jsp
    </result>
    <result name="input">/UI/EerrorPages/505.jsp</result>
    </action>
      

  3.   

    自己搞定,上传的ACTION不要用spring的bean