Spring Security权限报错-java.lang.IllegalArgumentException: Failed to evaluate expression ‘ROLE_USER’

控制台报错:

java.lang.IllegalArgumentException: Failed to evaluate expression 'ROLE_USER'

解决方法:

1.这个问题出现在Spring Security的相关配置中,找到这一行:

<security:intercept-url pattern="/**" access="ROLE_USER"/>

改成以下内容问题得以解决:

<security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>

2.或不使用表达式语言

<security:http auto-config="true">

更改为

<security:http auto-config="true" use-expressions="false">

你可能感兴趣的:(spring-security)