JSP使用<security:authorize access="hasPermission('read','formDialog:edit')">后,断点一直进的是DenyAllPermissionEvaluator的hasPermission方法
时间: 2023-06-18 15:06:45 浏览: 57
这个问题可能是因为您的应用程序中没有为`hasPermission()`方法配置正确的权限解析器。在使用Spring Security时,`hasPermission()`方法必须由一个权限解析器进行解析,以确定用户是否具有访问特定资源的权限。如果没有正确配置权限解析器,则无法正确解析此方法。
您可以尝试在您的代码中添加以下配置来配置权限解析器:
```xml
<bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
<property name="permissionEvaluator">
<bean class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler"/>
</property>
</bean>
<security:global-method-security pre-post-annotations="enabled" secured-annotations="enabled" jsr250-annotations="enabled" >
<security:expression-handler ref="expressionHandler"/>
</security:global-method-security>
```
这将为您的应用程序配置一个默认的`DefaultMethodSecurityExpressionHandler`权限解析器,并将其指定为表达式处理程序。
如果这个解决方案不起作用,您可以考虑在调试模式下打印出相关的Spring Security日志,以帮助您确定问题的根源。您可以通过在`log4j.properties`文件中添加以下配置来启用日志记录:
```
log4j.logger.org.springframework.security=DEBUG
```
这将启用所有Spring Security相关的日志记录。您可以根据需要调整日志记录级别。