我是春季安全新手。我想爲兩種不同類型的用戶提供兩種不同的登錄表單。我有一個名爲/ admin的包,其中包含我的系統用戶主要項目和其他用戶的/ portal ./portal用戶將在他們的租戶上工作,並且不會了解/ admin的任何信息,反之亦然。每個用戶組都有自己的數據庫也。 在spring-security.xml中,我定義了兩個身份驗證管理器,但是當我從兩個登錄表單登錄時,它將轉到「AuthenticatingManager」,但正如我在xml文件中所述,對於/ portal用戶,它應該轉到PortalAuthenticatingManager。我該怎麼辦?或者我錯過了什麼?春季安全多重身份驗證管理器
<security:http use-expressions="true" pattern="/portal/**" authentication-manager-ref="portalAuthMgr" access-denied-page="/unauthorized.jsp">
<form-login login-page="/plLogin.jsp" default-target-url="/portal/portal" />
<security:intercept-url pattern="/plLogin.jsp" access="permitAll"/>
<security:intercept-url pattern="/portal/**" access="hasRole('ROLE_PORTAL')" />
</security:http>
<security:http authentication-manager-ref="adminAuthMgr" access-denied-page="/unauthorized.jsp">
<intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<security:form-login login-page="/login.jsp" authentication-failure-handler-ref="authenticationFailureHandler"/>
</security:http>
<security:authentication-manager id="adminAuthMgr">
<security:authentication-provider ref="produxAuthenticationProvider"/>
</security:authentication-manager>
<security:authentication-manager alias="portalAuthMgr">
<security:authentication-provider ref="portalAuthenticationProvider"/>
</security:authentication-manager>
<beans:bean id="produxAuthenticationProvider" class="com.spring.AuthenticatingManager">
</beans:bean>
<beans:bean id="portalAuthenticationProvider" class="com.spring.PortalAuthenticatingManager">
</beans:bean>
您需要重新修改縮進: – kapad 2015-07-29 08:04:15