title: Multiple login form with different namespace in Spring Security
body: <p>I want to create two form-logins with different namespace, one for User login (namespace default "/") , one for Admin login with namespace "/admin".
  When I run program, the form-login for User run fine. But form-login for Admin run fail.</p>
  
  <p>This is my file spring security:</p>
  
  <pre><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.0.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-3.1.xsd"&gt;
  
  &lt;http pattern="/login*" security="none" /&gt;
  &lt;http pattern="/admin/" security="none" /&gt;
  
  &lt;http pattern="/admin/**"&gt;
      &lt;intercept-url pattern='admin/**' access='ROLE_ADMIN' /&gt;
      &lt;access-denied-handler error-page="/user/403.jsp" /&gt;
      &lt;form-login login-page="/adminLogin" default-target-url="/adminAccess"
          authentication-failure-url="/adminLogin?error" username-parameter="username"
          password-parameter="password" /&gt;
      &lt;logout logout-success-url="/adminLogin?logout" /&gt;
      &lt;http-basic /&gt;
  &lt;/http&gt;
  &lt;http&gt;
      &lt;intercept-url pattern="/user" access="ROLE_USER" /&gt;
      &lt;intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" /&gt;
      &lt;access-denied-handler error-page="/user/403.jsp" /&gt;
      &lt;form-login login-page="/login" default-target-url="/userAccess"
          authentication-failure-url="/login?error" username-parameter="username"
          password-parameter="password" /&gt;
      &lt;logout logout-success-url="/login?logout" /&gt;
  &lt;/http&gt;
  
  &lt;beans:bean id="daoAuthenticationProvider"
      class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"&gt;
      &lt;beans:property name="userDetailsService" ref="userDetailsService" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="authenticationManager"
      class="org.springframework.security.authentication.ProviderManager"&gt;
      &lt;beans:property name="providers"&gt;
          &lt;beans:list&gt;
              &lt;beans:ref local="daoAuthenticationProvider" /&gt;
          &lt;/beans:list&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;authentication-manager erase-credentials="false"&gt;
      &lt;authentication-provider user-service-ref="userDetailsService"&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I login in form-login for Admin (namespace "/admin"), The error happend with messeage "HTTP Status 404 - There is no Action mapped for namespace [/admin] and action name [j_spring_security_check] associated with context path [/Java-framework]. "</p>
  
  <p>The order filter in my web.xml file:</p>
  
  <pre><code>&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;!-- Define filter for Struts 2 --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;encodingFilter&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;encodingFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/* &lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Action in my struts.xml file:</p>
  
  <pre><code>&lt;package name="default" namespace="/" extends="struts-default"&gt;
      &lt;action name="login"&gt;  
          &lt;result&gt;USER_LOGIN_SPRING_SECURITY&lt;/result&gt;  
      &lt;/action&gt; 
      &lt;action name="userAccess" class="springAdminAction" method="execute"&gt;
          &lt;result name="success"&gt;USER_SPRING_SECURITY&lt;/result&gt;
      &lt;/action&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;package name="admin" namespace="/admin" extends="default-web-admin"&gt;
  &lt;action name="adminAccess" class="springAdminAction" method="execute"&gt;
          &lt;result name="success"&gt;ADMIN_SPRING_SECURITY&lt;/result&gt;
      &lt;/action&gt;       
  &lt;action name="adminLogin"&gt;
          &lt;result&gt;ADMIN_LOGIN_SPRING_SECURITY&lt;/result&gt;  
      &lt;/action&gt;
  </code></pre>
  
  <p></p>