Note that there are some explanatory texts on larger screens.

plurals
  1. POspring 3 uploadify giving 404 Error
    primarykey
    data
    text
    <p>I am using Spring 3 and implementing Uploadify. The problem is, the files are updating properly but it is giving HTTP Error 404, on completion of file upload. I tried every possible solution, but none of them works. </p> <p>The files are uploaded. Values are storing in DB properly, only that i am getting HTTP Error 404. Any help is appreciated and Thanks in advance.</p> <p><strong>The Solution is :</strong> </p> <pre><code>Finally i found the solution but it is lame. I removed the return "" and changed the method as void. Thats it. But still i don't understand why the same code is working in Spring 2.5.6 and not in 3. </code></pre> <p><strong>The URL of the screenshot</strong> : <a href="http://imgur.com/bf3qo" rel="nofollow">http://imgur.com/bf3qo</a></p> <p><strong>The JSP Page</strong></p> <pre><code>$(function() { $('#file_upload').uploadify({ 'swf' : 'scripts/uploadify.swf', 'fileObjName' : 'the_file', 'fileTypeExts' : '*.gif; *.jpg; *.jpeg; *.png', 'multi' : true, 'uploader' : '/photo/savePhoto', 'fileSizeLimit' : '10MB', 'uploadLimit' : 50, 'onUploadStart' : function(file) { $('#file_upload').uploadify('settings', 'formData', {'trip_id' :'1', 'trip_name' :'Sample Trip', 'destination_trip' :'Mumbai','user_id' :'1','email' :'s@s.com','city_id' :'12'}); }, 'onQueueComplete' : function(queueData) { console.log('queueData : '+queueData); window.location.href = "trip/details/1"; } }); }); </code></pre> <p><strong>The Controller</strong></p> <pre><code>@RequestMapping(value="photo/{action}", method=RequestMethod.POST) public String postHandler(@PathVariable("action") String action, HttpServletRequest request) { if(action.equals("savePhoto")) { try{ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request; MultipartFile file = multipartRequest.getFile("the_file"); String trip_id = request.getParameter("trip_id"); String trip_name = request.getParameter("trip_name"); String destination_trip = request.getParameter("destination_trip"); String user_id = request.getParameter("user_id"); String email = request.getParameter("email"); String city_id = request.getParameter("city_id"); photo.savePhoto(file,trip_id,trip_name,destination_trip,user_id,email,city_id); photo.updatetrip(photo_id,trip_id); }catch(Exception e ){e.printStackTrace();} } return ""; } **Solution** : Change the method return type as void and remove the return </code></pre> <p><strong>spring config</strong></p> <pre><code>&lt;bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver"&gt; &lt;property name="maxUploadSize" value="10000000"/&gt; &lt;/bean&gt; </code></pre> <p><strong>Web.xml is</strong> </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;display-name&gt;project_name&lt;/display-name&gt; &lt;distributable/&gt; &lt;context-param&gt; &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath:log4j.properties&lt;/param-value&gt; &lt;/context-param&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/project_name-servlet.xml,/WEB-INF/applicationContext-jdbc.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;project_name&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;project_name&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;session-config&gt; &lt;session-timeout&gt;60&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;/web-app&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload