Java 上传文件时某些IE出现错误

Java 上传文件时某些IE出现错误,java,javascript,jquery,internet-explorer,Java,Javascript,Jquery,Internet Explorer,面临着一种奇怪的情况。即使在IE中,下面的代码在任何地方都可以正常工作,但在某些IE中,它会产生下面的错误,只是不知道它为什么会出现以及如何解决这个问题。请帮帮我 // controller side code @RequestMapping(value = "upload", method=RequestMethod.POST) public @ResponseBody String upload(HttpServletRequest request, HttpServletResponse

面临着一种奇怪的情况。即使在IE中,下面的代码在任何地方都可以正常工作,但在某些IE中,它会产生下面的错误,只是不知道它为什么会出现以及如何解决这个问题。请帮帮我

// controller side code
@RequestMapping(value = "upload", method=RequestMethod.POST) 
public @ResponseBody String upload(HttpServletRequest request, HttpServletResponse response,
@RequestPart("dataFile") MultipartFile file
){ if(file!=null){
//code to upload file and will return 1
        return "1";
    }
    return "0";//otherwise it will return 0
}
//javascript中向控制器提交iframe(提交表单)的代码

<html>

<script language="Javascript">
function fileUpload(form, action_url, div_id) {
    // Create the iframe...
    var iframe = document.createElement("iframe");
    iframe.setAttribute("id", "upload_iframe");
    iframe.setAttribute("name", "upload_iframe");
    iframe.setAttribute("width", "0");
    iframe.setAttribute("height", "0");
    iframe.setAttribute("border", "0");
    iframe.setAttribute("style", "width: 0; height: 0; border: none;");

    // Add to document...
    form.parentNode.appendChild(iframe);
    window.frames['upload_iframe'].name = "upload_iframe";

    iframeId = document.getElementById("upload_iframe");

    // Add event...
    var eventHandler = function () {

            if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
            else iframeId.removeEventListener("load", eventHandler, false);

            // Message from server...
            if (iframeId.contentDocument) {
                content = iframeId.contentDocument.body.innerHTML;
            } else if (iframeId.contentWindow) {
                content = iframeId.contentWindow.document.body.innerHTML;
            } else if (iframeId.document) {
                content = iframeId.document.body.innerHTML;
            }

            document.getElementById(div_id).innerHTML = content;

            // Del the iframe...
            setTimeout('iframeId.parentNode.removeChild(iframeId)', 250);
        }

    if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
    if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);

    // Set properties of form...
    form.setAttribute("target", "upload_iframe");
    form.setAttribute("action", action_url);
    form.setAttribute("method", "post");
    form.setAttribute("enctype", "multipart/form-data");
    form.setAttribute("encoding", "multipart/form-data");

    // Submit the form...
    form.submit();

    document.getElementById(div_id).innerHTML = "Uploading...";
}
</script>

//html code 
<!-- index.php could be any script server-side for receive uploads. -->
<form>
<input type="file" name="dataFile" id="dataFile" /></br>
<input type="button" value="upload"
        onClick="fileUpload(this.form,'upload','uploadShow'); return false;" >
<div id="uploadShow"></div>
</form>

</html>

尝试直接在表单定义中添加所有属性,例如:您的理由有价值!谢谢,我会试着让你知道。某些版本的IE在
setAttribute方面存在重大问题。
在几乎所有情况下,都应该使用属性访问。抱歉,伙计们,问题不在于…尝试了,但结果是一样的。这里的文件是上传的,这意味着错误即将到来,而我们得到的响应是字符串,只有在那个时候错误正在发生。
PLATFORM VERSION INFO
                Windows                                                : 6.1.7601.65536 (Win32NT)
                Common Language Runtime               : 4.0.30319.1022
                System.Deployment.dll                         : 4.0.30319.1 (RTMRel.030319-0100)
                clr.dll                                      : 4.0.30319.1022 (RTMGDR.030319-1000)
                dfdll.dll                                   : 4.0.30319.1 (RTMRel.030319-0100)
                dfshim.dll                                               : 4.0.31106.0 (Main.031106-0000)

SOURCES
                Deployment url                                      : http://URL(cant show)

ERROR SUMMARY
                Below is a summary of the errors, details of these errors are listed later in the log.
                * Activation of http://URL(cant show) resulted in exception. Following failure messages were detected:
                                + Downloading http://URL(cant show) did not succeed.
                                + The remote server returned an error: (401) Unauthorized.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
                No transaction error was detected.

WARNINGS
                There were no warnings during this operation.

OPERATION PROGRESS STATUS
                * [30/04/2014 09:32:49] : Activation of http://URL(cant show) has started.

ERROR DETAILS
                Following errors were detected during this operation.
                * [30/04/2014 09:32:50] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
                                - Downloading http://URL(cant show) did not succeed.
                                - Source: System.Deployment
                                - Stack trace:
                                                at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
                                                at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
                                                at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
                                                at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
                                                at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
                                                at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
                                                at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
                                                at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
                                --- Inner Exception ---
                                System.Net.WebException
                                - The remote server returned an error: (401) Unauthorized.
                                - Source: System
                                - Stack trace:
                                                at System.Net.HttpWebRequest.GetResponse()
                                                at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)

COMPONENT STORE TRANSACTION DETAILS
                No transaction information is available.