zoukankan      html  css  js  c++  java
  • 【实用小技巧】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. 所有相关的配置文件


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

  • 相关阅读:
    当老板如何带团队?
    创业者第一法宝-了解自己
    交流才能交易,交易才能交心
    集合框架
    MySQL一些命令语法
    JS组成整理
    git中可以pull但是push提示Everything up-to-date的情况
    循环判断以及文件的使用--练习1
    Hello World !
    linux文件权限修改
  • 原文地址:https://www.cnblogs.com/oldwei/p/9282828.html
Copyright © 2011-2022 走看看