【问题标题】:Upload video in struts 2在struts 2中上传视频
【发布时间】:2013-06-05 05:44:12
【问题描述】:

我想在我的 struts 2 Web 应用程序中上传视频。为此,我使用 文件上传拦截器 。我的问题是,我能够成功上传图像和文本文件,但无法上传视频和闪存文件,文件参数在我的操作中没有得到初始化。我的做法如下:

struts.xml 中的条目:

<action name="uploadFile"
        class="com.infoshore.noticeboard.actions.DssUploadFileAction" method="addUploadContent">
        <interceptor-ref name="fileUpload">
            <param name="allowedTypes">
                image/png,image/gif,image/jpeg,image/pjpeg,image/jpg,video/x-ms-rmvb,video/x-ms-wmv,video/x-ms-avi,
                video/fli,video/x-fli,video/x-atomic3d-feature,video/gl,video/x-gl,video/x-isvideo,video/mpeg,video/x-motion-jpeg,video/quicktime,video/x-sgi-movie,
                video/x-mpeg,video/vnd.rn-realvideo,video/x-scm
            </param>
            <!-- <param name="allowedTypes">text/plain</param>  -->
            <param name="maximumSize">10485760</param>
        </interceptor-ref>
        <interceptor-ref name="logininterceptor" />
        <interceptor-ref name="params" />
        <interceptor-ref name="basicStack" />
        <result name="success" type="chain">dssUploadContent</result>
        <result name="input" type="chain">dssUploadContent</result>
        <result name="login">login.jsp</result>
    </action>

我在这里做错了什么,请告诉我。 谢谢。

【问题讨论】:

    标签: java file-upload struts2 request httprequest


    【解决方案1】:

    maximumSizeper-filegloballyper-Action

    <interceptor-ref name="fileUpload">
        <param name="maximumSize">10485760</param>
    </interceptor-ref>
    

    默认为 2097152 字节 (2 MB)

    multipart.maxSize

    <constant name="struts.multipart.maxSize" value="100485760" />
    

    按请求仅全局配置

    默认为 2097152 字节 (2 MB) (source on File Upload Advanced Configuration)


    混合这两个参数允许您在单个请求中上传 N 个 maximumSize MB 的文件,前提是它们不违反 struts.multipart.maxSize MB 定义的限制。

    More info here

    【讨论】:

      猜你喜欢
      • 2017-10-23
      • 2016-02-16
      • 1970-01-01
      • 2013-05-13
      • 2014-10-17
      • 2014-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多