title: Spring Security: 404 on logout
body: <p>When I try to access the logout URL of my spring application, I get a 404 error and <code>No mapping found for HTTP Request with URI [/logout] in DispatcherServlet with name 'mvc-dispatcher'</code> in my server log.</p>
  
  <p>I have already tried <a href="https://stackoverflow.com/questions/11050840/call-to-j-spring-security-logout-not-working">Call to j_spring_security_logout not working</a>, <a href="https://stackoverflow.com/questions/3068637/issue-with-spring-securitys-logout">Issue with Spring security&#39;s logout</a> and pretty much all of the related results on SO.</p>
  
  <p>I'm including the complete configuration files as the Spring xml structure isn't quite clear to me yet.</p>
  
  <p>My security configuration:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/security
          http://www.springframework.org/schema/security/spring-security.xsd"&gt;
  
      &lt;http pattern="/resources/**" security="none" /&gt;
  
      &lt;http auto-config="true"&gt;
          &lt;intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
          &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt;
          &lt;form-login login-page="/login" default-target-url="/"/&gt;
          &lt;logout logout-url="/logout" /&gt;
          &lt;csrf /&gt;
      &lt;/http&gt;
  
      &lt;global-method-security secured-annotations="enabled" /&gt;
  
      &lt;authentication-manager&gt;
          &lt;authentication-provider user-service-ref="userDetailsService" /&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>My <code>web.xml</code> is this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;display-name&gt;XYZ&lt;/display-name&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/*-config.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&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;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;/web-app&gt;
  </code></pre>
  
  <p>How do I make the logout page work?</p>