title: spring security redirect based on role
body: <p>i have the following spring-security.xml file :-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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.0.xsd"&gt;
  
      &lt;http auto-config="true"&gt;
             &lt;intercept-url pattern="/Freelancer/**" access="ROLE_FREELANCE" /&gt;
             &lt;intercept-url pattern="/Client/**" access="ROLE_CLIENT" /&gt;
             &lt;intercept-url pattern="/Agency/**" access="ROLE_AGENCY" /&gt;
             &lt;intercept-url pattern="/Manager/**" access="ROLE_MANAGER" /&gt;
             &lt;intercept-url pattern="/User/**" access="ROLE_USER" /&gt;
             &lt;form-login default-target-url="/${role}" login-page="/login.jsp" /&gt;
             &lt;logout logout-url="/logout" logout-success-url="/" /&gt;
      &lt;/http&gt;
  
      &lt;authentication-manager&gt;
             &lt;authentication-provider&gt;
               &lt;jdbc-user-service data-source-ref="dataSource" 
                 users-by-username-query="select user_name,password, enabled from Users where user_name=?"  
                 authorities-by-username-query="select u.user_name, u.role from Users u where u.user_name =?"/&gt;                 
             &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;  
  </code></pre>
  
  <p>what i want, i want to redirect the user to their workspace, for example if Client login then he will be redirected to the /Client/index.jsp, if Agency login, they will be redirected to the /Agency/index.jsp.</p>
  
  <p>is there any way to access the role before, he will be redirected to their workspace in spring-security.xml file.</p>
  
  <pre><code>&lt;form-login default-target-url="/${role}" login-page="/login.jsp" /&gt;
  </code></pre>
  
  <p>I have the directory structure similer to role.</p>
  
  <p>have any idea.</p>