java - IE is taking response of controller as a file -


The following is the code where I tried to upload the file with my code, the code is working properly in Chrome and Mozilla But it is not working for IE.For IE when the Controller Return Ent (which shows whether the file has been successfully uploaded or not) This uploads the browser as a file and for this reason to open or save this file And ifi opens that file in Notepad Land, indicating that brick which is based on 1 or 0 result, I do not know that taking him in as a file. Please help me

  // Requesting Mail Configuration (Value = "Upload", Method = Request Post) // @ Production (Text / HTML) Try this type, but the results change Could not. Public @ResponseBody int upload (HttpServletRequest request, HttpServletResponse response, @RequestPart ("datafile" MultipartFile file) {write code to a directory on the specified directory, which gives 1 on success and 0} on failure}   

// The code is in javascript, which is the iframe (which submits the form) to the controller

   gt; script language = "javascript"> function Upload file (form, action_urvol, dev_id) {// create iframe ... var iframe = document.createElement Iframe.setAttribute ("id", "upload_iframe"); Iframe.setAttribute ("name", "upload_iframe"); iframe.setAttribute ("width", "0"); iframe.setAttribute (" Iframe.setAttribute ("border", "0"); Iframe.setAttribute ("style", "width: height; 0; limit: none;"); // add to document. ... file.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", event right handler, incorrect); // Message from server ... if (iframeId.contentDocument) {content = iframeId.contentDocument.body.inner html; } And if (iframeId.contentWindow) {content = iframeId.contentWindow.document.body.innerHTML; } And if (iframeId.document) {content = iframeId.document.body.inner html; } Document.getElementById (div_id) .innerHTML = content; // daily iframe ... setTimeout ('iframeId.parentNode.removeChild (iframeId)', 250); } If (iframeId.addEventListener) iframeId.addEventListener ("load", eventHandler, is true); If (iframeId.attachEvent) iframeId.attachEvent ("Onload", EventMahler); // Set the property of the form ... form.setAttribute ("target", "upload_iframe"); Form.setAttribute ("Action", Action_Rill); Form.setAttribute ("method", "post"); Form.setAttribute ("Encrypt", "Multipart / Form-Data"); Form.setAttribute ("Encoding", "Multipart / Form-Data"); // Submit form ... form.submit (); Document.getElementById (div_id). WinnerHTML = "Uploading ..."; } & Lt; / Script & gt; // HTML code & lt ;! - Any script to get index.php upload can be server-side. - & gt; & Lt; Form & gt; & Lt; Input type = "file" name = "datafile" id = "datafile" /> gt; & Lt; / Br & gt; & Lt; Input type = "button" value = "upload" onClick = "fileUpload (this.form, 'upload', 'show upload'); return back;" & Gt; & Lt; Div id = "show upload" & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Html & gt; // Resolver public class AppConfig {// / WEB-INF / views Guide the logical view names for .jsp resources in the @ Bean ViewResolver viewResolver () {InternalResourceViewResolver resolver = New InternalResourceViewResolver (); Resolver.setPrefix ("web-INF / views /"); resolver.setSuffix ("jsp."); Return resolver; }}    

Sorry for the late reply. I had to setup the Spring MVC environment before trying your code.

I have changed the type of return from the controller method to string and apparently it works now can you give it a try. "Return" 1};} return "0";}

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -