gboat2.base.plugin.struts.interceptor
类 GboatFileUploadInterceptor

java.lang.Object
  继承者 com.opensymphony.xwork2.interceptor.AbstractInterceptor
      继承者 org.apache.struts2.interceptor.FileUploadInterceptor
          继承者 gboat2.base.plugin.struts.interceptor.GboatFileUploadInterceptor
所有已实现的接口:
com.opensymphony.xwork2.interceptor.Interceptor, Serializable

public class GboatFileUploadInterceptor
extends org.apache.struts2.interceptor.FileUploadInterceptor

此拦截器经过改装:目的是实现断点上传后端接收数据。
改装的点用注释线隔开,分为三部分:
1.断点续传所需变量;
2.请求已经上传文件大小;
3.把文件片段上传到服务器;

 1. 在 Struts.xml 中定义拦截器:
    <interceptor name="fileUpload" class="gboat2.base.plugin.struts.interceptor.GboatFileUploadInterceptor" />
 2. 定义一个拦截器栈,并将 fileUpload 添加到该栈中:
    <interceptor-stack name="gboat2Stack">
        <interceptor-ref name="fileUpload">
            <!-- 允许上传的文件后缀 -->
            <param name="allowedExtensions">.gif,.bmp,.png,.jpg,.jpeg,.tiff,.tif,.mpg</param>
        </interceptor-ref>
    </interceptors>
 3. 将刚才定义的拦截器栈设置为默认执行: <default-interceptor-ref name="gboat2Stack" />
 4. 可以在 javaWeb 项目的 web.xml 中添加如下配置,扩展允许上传的文件后缀:
    <context-param>
        <description>允许上传的文件后缀</description>
        <param-name>fileupload.extra.allowed.extensions</param-name>
        <param-value>
            .pdf,.doc,.docx,.wps,.xls,.xlsx,.ppt,.pptx,.txt
        </param-value>
    </context-param>
 

从以下版本开始:
1.0
作者:
zhangxj-a, 何明旺
另请参见:
序列化表格

字段摘要
 
从类 org.apache.struts2.interceptor.FileUploadInterceptor 继承的字段
allowedExtensionsSet, allowedTypesSet, LOG, maximumSize
 
构造方法摘要
GboatFileUploadInterceptor()
           
 
方法摘要
 String getMultipartSaveDir()
           
 String intercept(com.opensymphony.xwork2.ActionInvocation invocation)
           
 void setAllowedExtensions(String allowedExtensions)
           
 void setMultipartSaveDir(String multipartSaveDir)
           
 void setServletContext(javax.servlet.ServletContext context)
           
 
从类 org.apache.struts2.interceptor.FileUploadInterceptor 继承的方法
acceptFile, getTextMessage, getTextMessage, setAllowedTypes, setContainer, setMatcher, setMaximumSize
 
从类 com.opensymphony.xwork2.interceptor.AbstractInterceptor 继承的方法
destroy, init
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

GboatFileUploadInterceptor

public GboatFileUploadInterceptor()
方法详细信息

getMultipartSaveDir

public String getMultipartSaveDir()

setServletContext

public void setServletContext(javax.servlet.ServletContext context)

setAllowedExtensions

public void setAllowedExtensions(String allowedExtensions)
覆盖:
org.apache.struts2.interceptor.FileUploadInterceptor 中的 setAllowedExtensions

setMultipartSaveDir

public void setMultipartSaveDir(String multipartSaveDir)

intercept

public String intercept(com.opensymphony.xwork2.ActionInvocation invocation)
                 throws Exception
指定者:
接口 com.opensymphony.xwork2.interceptor.Interceptor 中的 intercept
覆盖:
org.apache.struts2.interceptor.FileUploadInterceptor 中的 intercept
抛出:
Exception


Copyright © 2014 广联达软件股份有限公司(Glodon Software Co., Ltd.). All rights reserved.