Java 定义了通用匹配模式(';/**';)。。。尝试将spring安全性添加到项目时出错
我正在尝试将spring安全性添加到我的项目中,我已经尝试使用在internet上找到的所有解决方案,但没有任何效果。你有什么想法吗?? 堆栈跟踪:Java 定义了通用匹配模式(';/**';)。。。尝试将spring安全性添加到项目时出错,java,spring-security,Java,Spring Security,我正在尝试将spring安全性添加到我的项目中,我已经尝试使用在internet上找到的所有解决方案,但没有任何效果。你有什么想法吗?? 堆栈跟踪: Caused by: java.lang.IllegalArgumentException: A universal match pattern ('/**') is defined before other patterns in the filter chain, causing them to be ignored. Please chec
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
at org.springframework.security.config.http.DefaultFilterChainValidator.checkPathOrder(DefaultFilterChainValidator.java:51)
at org.springframework.security.config.http.DefaultFilterChainValidator.validate(DefaultFilterChainValidator.java:40)
...
原因:java.lang.IllegalArgumentException:在筛选器链中的其他模式之前定义了通用匹配模式('/**'),导致它们被忽略。请检查命名空间或FilterChainProxy bean配置中的顺序
位于org.springframework.security.config.http.DefaultFilterChainValidator.checkPathOrder(DefaultFilterChainValidator.java:51)
位于org.springframework.security.config.http.DefaultFilterChainValidator.validate(DefaultFilterChainValidator.java:40)
...
web.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app ..>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/context.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Web应用程序创建的原型
调度员
org.springframework.web.servlet.DispatcherServlet
1.
调度员
/
上下文配置位置
/WEB-INF/context.xml,
/WEB-INF/spring-security.xml
org.springframework.web.context.ContextLoaderListener
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
spring-security.xml:
<beans:beans ...>
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/admin**" access="hasRole('role_admin')" />
<access-denied-handler error-page="/403" />
<form-login
login-page="/user/login"
default-target-url="/index"
authentication-failure-url="/index"
username-parameter="username"
password-parameter="password" />
<logout logout-success-url="/index" />
</http>
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,password from users where username=?"
authorities-by-username-query=
"select username, role from users join user_roles using(id_user_roles) where username =?" />
</authentication-provider>
</authentication-manager>
</beans:beans>
是否要从我的项目中添加或附加一些其他.xml文件?看起来您可能有另一个
元素,或某个过滤器ChainProxy
bean定义。您可以帮助我如何配置其中一个吗?我在网上找不到任何可以理解的解决办法。