2014-02-27 50 views
0

我在春天是新的,我想補充自定義註銷春

<security:logout invalidate-session="true" success-handler-ref="myLogoutHandler" logout-url="/logout" /> 

在春季安全配置,但我得到的錯誤

vc-complex-type.3.2.2: Attribute 'success-handler-ref' is not allowed to appear in element 'security:logout'. 

如何解決這個問題?

我的文件看起來像這樣

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:security="http://www.springframework.org/schema/security" 
    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-2.0.xsd 
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> 

    <security:global-method-security /> 

    <security:http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint"> 
     <security:intercept-url pattern="/index.jsp" filters="none" /> 
     <security:intercept-url pattern="/*.action" access="ROLE_USER" /> 
     <security:logout logout-success-url="/index.jsp" invalidate-session="true" logout-url="/logout" /> 
     <security:logout invalidate-session="true" success-handler-ref="myLogoutHandler" logout-url="/logout" /> 


    </security:http> 

    <bean id="authenticationProcessingFilter" class="com.loiane.security.MyAuthenticationProcessingFilter"> 
     <security:custom-filter position="AUTHENTICATION_PROCESSING_FILTER" /> 
     <property name="defaultTargetUrl" value="/main.html" /> 
     <property name="authenticationManager" ref="authenticationManager" /> 
    </bean> 



    <security:authentication-manager alias="authenticationManager" /> 

    <bean id="authenticationProcessingFilterEntryPoint" 
     class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint"> 
     <property name="loginFormUrl" value="/index.jsp" /> 
     <property name="forceHttps" value="false" /> 
    </bean> 

    <!-- 
    Usernames/Passwords are 
     rod/koala 
     dianne/emu 
     scott/wombat 
     peter/opal 
    These passwords are from spring security app example  
    --> 

    <security:authentication-provider> 
     <security:password-encoder hash="md5"/> 
     <security:user-service> 
      <security:user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" /> 
      <security:user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" /> 
      <security:user name="scott" password="2b58af6dddbd072ed27ffc86725d7d3a" authorities="ROLE_USER" /> 
      <security:user name="peter" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" /> 
     </security:user-service> 
    </security:authentication-provider> 
</beans> 
+0

檢查您的彈簧安全配置中的導入命名空間和xsds – Keerthivasan

回答

0

你都宣稱 '安全:註銷' 兩次(兩個不同的線路)。

此外,根據模式,'註銷'下不允許'success-handler-ref'。這就是你得到錯誤的原因。

以前,I've written a short doc about Spring's Logout。它可能有幫助。

+0

如果我刪除了這個如何寫myLogoutHandler的bean如 user3106347

+0

我已編輯並添加了一個鏈接... – OhadR

0

模式http://www.springframework.org/schema/security/spring-security-2.0.xsd適用於Spring 2.0版。屬性success-handler-ref在此版本的Spring Security中不存在。換成http://www.springframework.org/schema/security/spring-security-3.2.xsd。這假定你正在使用Spring Security 3.2。

如果您使用的是Spring Security 2.0,則應考慮更新,因爲2.0已過期。