【实用小技巧】spring springmvc集成shiro时报 No bean named 'shiroFilter' available

查了网上的,很多情况,不同的解决办法,总归一点就是配置文件加载的问题。

先看下配置文件中的配置

  1. web.xml中的主要配置(这是修改后不在报错的;仅仅修改了一个位置:【classpath:spring-*.xml 改为classpath*:spring-*.xml 】仅仅多了一个*号)
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:spring-*.xml</param-value>
    	</context-param>
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	
      	<!-- 配置Shiro过滤器 -->
    	<filter>
    		<filter-name>shiroFilter</filter-name>
    		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    		<init-param>
    			<!-- 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由servlet container管理 -->
    			<param-name>targetFilterLifecycle</param-name>
    			<param-value>true</param-value>
    		</init-param>
    	</filter>
    
    	<filter-mapping>
    		<filter-name>shiroFilter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
      	
      
    	<servlet>
    		<servlet-name>springDispatcherServlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>classpath:springmvc.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>springDispatcherServlet</servlet-name>
    		<url-pattern>/</url-pattern>
    	</servlet-mapping>
    
  2. 所有相关的配置文件


提示:注意配置文件名字,加载顺序,是否真的加载了。

猜你喜欢

转载自www.cnblogs.com/oldwei/p/9282828.html
今日推荐