2016-01-12 15 views
-1

這是我的安全xml文件。Spring安全沒有工作。錯誤是org.springframework.beans.factory.BeanCreationException

彈簧security.xml文件

<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.xsd 
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-3.2.xsd"> 
    <http auto-config="true"> 
      <intercept-url pattern="/user**" access="ROLE_USER" /> 
      <intercept-url pattern="/admin**" access="ROLE_ADMIN" /> 
     <form-login 
      always-use-default-target="true" 
      login-page="/login" 
      default-target-url="/welcome" 
      login-processing-url="/checkUser" 
      authentication-failure-url="/login?error" 
      username-parameter="username" 
      authentication-success-handler-ref="authenticationSuccessHandler" 
      password-parameter="password" /> 
     <logout logout-url="/login?logout" /> 
     <csrf/> 
    </http> 
    <authentication-manager> 
     <authentication-provider> 
      <user-service> 
       <user name="user" password="123456" authorities="ROLE_USER" /> 
       <user name="admin" password="123456" authorities="ROLE_ADMIN" /> 
      </user-service> 
     </authentication-provider> 
    </authentication-manager> 

</beans:beans> 

這是我CustomAuthenticationSuccessHandler和這個類從AuthenticationSuccessHandler接口實現。

CustomAuthenticationSuccessHandler

package com.mehman.puyment.security; 
import java.io.IOException; 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import org.springframework.security.core.Authentication; 
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 

public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler { 

    @Override 
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, 
      Authentication authentication) throws IOException, ServletException { 
     System.out.println("!***********************************************!"); 
    } 
} 
+1

後堆棧跟蹤定義ID authenticationSuccessHandler豆和類CustomAuthenticationSuccessHandler ... –

回答

0

你應該在彈簧security.xml文件

+0

我創建的servlet-dispatcher.xml豆文件。 –

+0

+0

對不起。你們是對的。問題解決了。感謝您的幫助。 –

相關問題