title: (Spring MVC) Upload multipartfile method POST returns 404 error
body: <p>I have a Spring application with an update file form:</p>
  
  <pre><code>&lt;form class="form-inline" role="form" method="POST" enctype="multipart/form-data"
                    action="&lt;c:url value="upload" /&gt;"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label class="control-label"&gt; &lt;spring:message code="file.to.upload"/&gt; &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;input type="file" name="file" id="file" class="btn btn-primary"&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;input
                              type="submit"
                              class="btn btn-primary"
                              value=&lt;spring:message code="upload"/&gt;&gt;
  
                  &lt;/div&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>But when I submit the form I get a 404 error which description says resource () not available. Note that it doesn't say "(/upload)", just an empty ().</p>
  
  <p>My (not reached) controller is:</p>
  
  <pre><code>@Controller
  @Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
  public class WebController implements Serializable {
  ...
  
  @RequestMapping(value="upload", method=RequestMethod.POST)
  public String handleFileUpload(
          @RequestParam("file") MultipartFile file, ModelMap model) throws     CloneNotSupportedException {
      System.out.println("Handling file");
      ... //never reaches here
      return screen(model);
  }
  </code></pre>
  
  <p>And I have this in my mvc-dispatcher-servlet.xml:</p>
  
  <pre><code>&lt;beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:jpa="http://www.springframework.org/schema/data/jpa"
     xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
     xmlns="http://www.springframework.org/schema/beans"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
  &lt;context:component-scan base-package="package.*"/&gt;
  
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/pages/"/&gt;
      &lt;property name="suffix" value=".jsp"/&gt;
  &lt;/bean&gt;
  
  &lt;jpa:repositories base-package="package"/&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  &lt;mvc:annotation-driven/&gt;
  &lt;!-- Root Context: defines shared resources visible to all other web components --&gt;
  &lt;bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
      &lt;property name="maxUploadSize"&gt;
          &lt;value&gt;104857600&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="maxInMemorySize"&gt;
          &lt;value&gt;4096&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:basename="resources/locale/strings"&gt;
      &lt;property name="defaultEncoding" value="UTF-8"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="localeChangeInterceptor"
        class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
      &lt;property name="paramName" value="locale"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="localeResolver"
        class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt;
      &lt;property name="defaultLocale" value="es"/&gt;
      &lt;property name="cookieName" value="myAppLocaleCookie"&gt;&lt;/property&gt;
      &lt;property name="cookieMaxAge" value="3600"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" &gt;
      &lt;property name="interceptors"&gt;
          &lt;list&gt;
              &lt;ref bean="localeChangeInterceptor" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;mvc:interceptors&gt;
      &lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
          &lt;property name="paramName" value="locale"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  &lt;/mvc:interceptors&gt;
  
  &lt;mvc:resources mapping="/resources/**" location="/resources/"/&gt;
  
  &lt;!-- EntityManagerFactory --&gt;
  &lt;bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory"&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  
  
  &lt;!-- Enable @Transactional annotation --&gt;
  &lt;tx:annotation-driven/&gt;
  </code></pre>
  
  <p></p>
  
  <p>And web.xml</p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns="http://java.sun.com/xml/ns/javaee"
       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;!-- Spring Security Configuration File --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/spring-security.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Creates the Spring Container shared by all Servlet and Filters --&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.security.web.session.HttpSessionEventPublisher&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- Spring Security Filter --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  
  &lt;!--End security--&gt;
  
  &lt;!-- Spring MVC - START --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
      &lt;filter-class&gt;
          org.springframework.web.filter.CharacterEncodingFilter
      &lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;encoding&lt;/param-name&gt;
          &lt;param-value&gt;UTF-8&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;/&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher&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;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.css&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.js&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;session-config&gt;
      &lt;session-timeout&gt;60&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  <p></p>
  
  <p>In the maven pom file:</p>
  
  <pre><code>&lt;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.springapp&lt;/groupId&gt;
  &lt;artifactId&gt;Project&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;Project&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;jdk.version&gt;1.6&lt;/jdk.version&gt;
      &lt;spring.version&gt;3.2.8.RELEASE&lt;/spring.version&gt;
      &lt;spring.security.version&gt;3.2.3.RELEASE&lt;/spring.security.version&gt;
      &lt;jstl.version&gt;1.2&lt;/jstl.version&gt;
      &lt;mysql.connector.version&gt;5.1.30&lt;/mysql.connector.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.8.2&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;jstl&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
          &lt;version&gt;1.2.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Hibernate --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;4.3.3.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;4.3.3.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
          &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
          &lt;version&gt;2.2.9&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.json&lt;/groupId&gt;
          &lt;artifactId&gt;json&lt;/artifactId&gt;
          &lt;version&gt;20080701&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Everything Else for database--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;${mysql.connector.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
          &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;xerces&lt;/groupId&gt;
          &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
          &lt;version&gt;2.11.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring Security --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;version&gt;2.3.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.13&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.13&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
          &lt;artifactId&gt;commons-math3&lt;/artifactId&gt;
          &lt;version&gt;3.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi&lt;/artifactId&gt;
          &lt;version&gt;3.10-FINAL&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
          &lt;version&gt;3.10-FINAL&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi-ooxml-schemas&lt;/artifactId&gt;
          &lt;version&gt;3.10-FINAL&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;joda-time&lt;/groupId&gt;
          &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
          &lt;version&gt;2.3&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
          &lt;version&gt;3.3.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.3.1&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;finalName&gt;Pronject&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;includes&gt;
                      &lt;include&gt;**/*Tests.java&lt;/include&gt;
                  &lt;/includes&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks</p>