从Struts2文件上传实用程序发布ajaxForm不能在IE中工作 [英] Post ajaxForm from Struts2 file upload utility not working in IE

查看:97
本文介绍了从Struts2文件上传实用程序发布ajaxForm不能在IE中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后台:
我正在寻找一个使用ajax + Struts2异步上传大文件的工具,我能够使用servlet做同样的事情,但是当我修改要调用的逻辑时struts行动。我注意到当我尝试使用struts2动作上传一个巨大的文件时,它不会从jquery ajaxForm(options)调用;

我使用了以下链接中指定的示例代码,这完全正常。
http:// www .simplecodestuffs.com / file-upload-with-progress-bar-using-jquery-in-servlet /

I have used the sample code specified on the below link this works perfectly fine. http://www.simplecodestuffs.com/file-upload-with-progress-bar-using-jquery-in-servlet/

任何人都可以判断是否在jquery函数调用之下对于上传功能是正确的。 $(#uploadtest)。ajaxForm(options);

Can anyone tell if below jquery function call is correct for upload functionality. $("#uploadtest").ajaxForm(options);

我试过但它没有按预期工作在上传大量数据时在一个特定的浏览器中。 (也就是说,发生客户端ajax调用,但是后端没有调用相应的struts2操作,在服务器端没有生成日志)。当jquery ajaxform 上传大文件(分段上传功能)时,我无法理解为什么没有调用struts2动作。

I tried but it is not working as expected in one particular browser when huge data is uploaded. (That is, client ajax call occurs, however, the corresponding struts2 action is not getting called in the backend, logs are not generated on the server side). I am not able to understand why struts2 action is not getting called when jquery ajaxform to upload huge file (multipart upload functionality).

jquery
$(#uploadtest)。ajaxForm(options);

jsp代码段
< s:表单ID =uploadtestname =uploadformaction =aStrutsActionmethod =post enctype =multipart / form-data>

此处询问类似问题.. IE8 / 9中的形式数据

Similar question is asked here ..FormData in IE8/9

推荐答案

上传大的问题Struts2操作的文件是该请求可能不符合Struts2默认使用的限制。在配置设置中,该值设置为2097152.您还可以设置每个操作的限制。有关它的更多信息,请参阅 Struts2文件上传 - 高级配置

The problem with uploading big files to the Struts2 action is that request may not comply the limits used by default with Struts2. In configuration settings the value is set to 2097152. You can also set the limits per action. More about it you can find in Struts2 File Upload - Advanced Configuration:


Struts 2 default.properties 文件定义了几个影响行为的设置文件上传。您可能需要更改这些值。名称和默认值为:

The Struts 2 default.properties file defines several settings that affect the behavior of file uploading. You may find in necessary to change these values. The names and default values are:

struts.multipart.parser=jakarta
struts.multipart.saveDir=
struts.multipart.maxSize=2097152







此文档页面的下一部分是文件大小限制你注意到下划线框架使用的文件大小的限制(struts2,commons-fileupload):


The next section from this docs page is File Size Limits where you have noticed about limitations of the file size used by the underline frameworks (struts2, commons-fileupload):


有两个单独的文件大小限制。首先是
struts.multipart.maxSize 来自Struts 2
default.properties 文件。出于安全原因,此设置存在于
禁止恶意用户将极大的文件上载到服务器磁盘空间的
。此设置默认为大约2
兆字节,应调整为您需要框架接收的最大大小文件( 2 gigs max
。如果您要在表单上上传
多个文件,则 struts.multipart.maxSize 会将
合并为总计,而不是单个文件大小。另一个设置
maximumSize ,是一个拦截器设置,用于确保
特定的Action不会收到太大的文件。请注意
以下示例中两个设置的位置:

There are two separate file size limits. First is struts.multipart.maxSize which comes from the Struts 2 default.properties file. This setting exists for security reasons to prohibit a malicious user from uploading extremely large files to file up your servers disk space. This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive. If you are uploading more than one file on a form the struts.multipart.maxSize applies to the combined total, not the individual file sizes. The other setting, maximumSize, is an interceptor setting that is used to ensure a particular Action does not receive a file that is too large. Notice the locations of both settings in the following example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.multipart.maxSize" value="1000000" />

    <action name="doUpload" class="com.example.UploadAction">
        <interceptor-ref name="basicStack"/>
        <interceptor-ref name="fileUpload">
            <param name="maximumSize">500000</param>
        </interceptor-ref> 
        <interceptor-ref name="validation"/>
        <interceptor-ref name="workflow"/>

        <result name="success">good_result.jsp</result>
    </action>
</struts>







如果文件大小超过上述配置设置,伪进度条会在返回响应后立即停止。它可能是1%或100%,它取决于阈值速度和文件大小。但在服务器端,您可能会看到异常


If the file size exceeds the above configuration settings, the pseudo progress bar stops as soon as it returns a response. It could be 1% or 100% it depends on thresh speed and a file size. But on the server side you might see an exception

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (xxx) exceeds the configured maximum (yyy)

以及以下警告。如果框架本身没有超出框架的限制,您可以使用框架调整文件大小限制。

and the following warnings. You might adjust the file size limitations with the framework if it doesn't exceed the framework's limitations itself.

这篇关于从Struts2文件上传实用程序发布ajaxForm不能在IE中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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