Springsecurity3.1.3 Configuring multiple landing pages

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.