今天在写SpringSecurity框架的课后代码出现了如下问题(启动tomcat报错):
Caused by: java.lang.IllegalArgumentException: A universal match pattern (’/**’) is defined before other patterns in the filter chain, causing them to be ignored. Please check the ordering in your security:http namespace or FilterChainProxy bean configuration.
检查后发现是web.xml配置加载类路径配置文件顺序的问题。
<!-- 配置加载类路径的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml,classpath*:spring-security.xml</param-value>
</context-param>
应该改为:
<!-- 配置加载类路径的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-security.xml
classpath:applicationContext.xml
</param-value>
</context-param>