Upload video in struts 2

瘦欲@ 提交于 2019-12-20 04:24:18

问题


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:

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.


回答1:


The maximumSize is per-file, configured globally OR per-Action

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

The default is 2097152 bytes (2 MB)

The multipart.maxSize

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

is per-request, configured only globally;

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


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.

More info here



来源:https://stackoverflow.com/questions/16932363/upload-video-in-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!