Requirements: The site's foreground and background of different URLs need different landing pages, different ways to catch the exception.
spring-security3.1 later versions support multiple
The Spring-security.xml is configured as follows
<!--Background Management - <httppattern= "/admin/**"Authentication-manager-ref= "AuthManager" > <Intercept-urlpattern= "/admin/login**"Access= "is_authenticated_anonymously" /> <Intercept-urlpattern= "/admin/**"Access= "Role_admin" /> <Form-loginLogin-page= "/admin/login.jsp"Authentication-failure-url= "/admin/login_fail.jsp"Default-target-url= "/admin/index.jsp"Login-processing-url= "Your url"/> </http> <!--Front desk - <httppattern= "/mycenter/**"Authentication-manager-ref= "AuthManager"> <Intercept-urlpattern= "/front/login**"Access= "is_authenticated_anonymously" /> <Intercept-urlpattern= "/mycenter/**"Access= "Role_user" /> <Form-loginLogin-page= "/front/login.jsp"Authentication-failure-url= "/front/login_fail.jsp"Default-target-url= "/front/index.jsp"Login-processing-url= "Your url"/> </http>
When configured as described above, the current logged-on user information cannot be obtained in the program code. Securitycontextholder.getcontext () is empty. Especially in the program section of the URL that is not in the foreground background regular match.
This occurs because two HTTP intercepts two specific URL expressions, then the remaining URLs will not be blocked by springsecurity, so there is no way to obtain the corresponding URL of the current user information.
The workaround is to add a third
Springsecurity3.1.3 Configuring multiple landing pages