在struts 2中上传视频 [英] Upload video in struts 2

查看:24
本文介绍了在struts 2中上传视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 struts 2 Web 应用程序中上传视频.为此,我使用 文件上传拦截器.我的问题是,我可以成功上传图片和文本文件,但不能上传视频和 Flash 文件,我的操作中没有初始化文件参数.我的做法如下:

I want to upload video in my struts 2 web application. For this I am using File upload interceptor . My problem is that, I am able to upload image and text file successfully, but not able to video and flash files, file parameters are not get initialize in my action. I am doing in the following way:

struts.xml 中的条目:

entry in 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>

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

What wrong I am doing here, please tell me. Thanks.

推荐答案

maximumSize每个文件,配置全局每个操作

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

默认为 2097152 字节 (2 MB)

The default is 2097152 bytes (2 MB)

multipart.maxSize

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

每个请求仅全局配置

默认值为 2097152 字节(2 MB)(文件上传高级配置的来源)

The default is 2097152 bytes (2 MB) (source on File Upload Advanced Configuration)

混合这两个参数允许您在单个请求中上传 maximumSize MB 的 N 个文件,如果它们不破坏 struts.multipart.maxSize MB 定义限制.

Mixing this two parameters allows you to upload N files of maximumSize MB each one in a single request, if they do not break the struts.multipart.maxSize MB defined limit.

此处有更多信息

这篇关于在struts 2中上传视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆