关于SSM+shiro安全框架,No bean named 'shiroFilter' is defined 错误

先说出现错误的可能原因吧!

1:web.xml配置中的filter-name的shiroFilter 与 spring-shiro.xml 中的 beanid命名的shiroFilter不一致。

2:保证在启动WEB容器的时候能加载到 spring-shiro.xml 文件,检查文件路径是否正确,参考:classpath*:spring-shiro.xml。

3:很有可能是在web.xml中没有配置监听器类ContextLoaderListener,导致即使加载了spring-shiro.xml,但是未保存到上下文环境中,从而导致No bean named 'shiroFilter' is defined 。

4:其它原因

 

下面是web.xml部分配置和spring-shiro.xml的配置:

 

web.xml中的配置:

 
      
    
    
        
        contextConfigLocation
        
            classpath*:spring-shiro.xml
        

    

    
    
   
        org.springframework.web.context.ContextLoaderListener
   

    
    
    
        shiroFilter
        org.springframework.web.filter.DelegatingFilterProxy
    
    
    
        shiroFilter
        /*
    

 

 

 

 

 

spring-shiro.xml中的配置:


    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-3.0.xsd"
    default-lazy-init="true">
 
    
    
        
        
        
    

    
    
    
        
        
        
        
           
               
               
           

       

    

 
    
    
 
    
    
    
 
    
    
        
        
        
        
        
        
        
            
                /login.jsp = anon
                /user/logon = anon
                /index.jsp = authc
                /admin/** = roles[admin]
                /user/** = roles[user]
                /logout=logout
                /** = authc
            

        

    

 
 

 

   

你可能感兴趣的:(关于SSM+shiro安全框架,No bean named 'shiroFilter' is defined 错误)