打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Spring Security3 SpEL表达式

Spring Security3 SpEL表达式

2012-09-16 15:29:12| 分类: spring | 标签:spring security spel |举报 |字号 订阅

启用SpELl表达式:在http元素里添加: use-expressions="true"
如: <http auto-config="true" use-expressions="true"> ...</http>

Spring Security 3 提供的 SpEL 方法和伪属性在以下的表格中进行了描述。要注意的是没有被标明“ web only ”的方法和属性可以在保护其他类型的资源中使用,如在保护方法调用时。示例表示的方法和属性是使用在<intercept-url> access 声明中。

方法

Web only?

描述

示例

hasIpAddress

(ipAddress)

Yes

用于匹配一个请求的 IP 地址或一个地址的网络掩码

access="hasIpAddress('

162.79.8.30')"

access="hasIpAddress('

162.0.0.0/224')"

hasRole(role)

No

用于匹配一个使用GrantedAuthority 的角色(类似于 RoleVoter )

access="hasRole('ROLE

USER')"

hasAnyRole(role)

No

用于匹配一个使用GrantedAuthority 的角色列表。用户匹配其中的任何一个均可放行。

access="hasRole('ROLE_

USER','ROLE_ADMIN')"

除了以上表格中的方法,在 SpEL 表达式中还有一系列的方法可以作为属性。它们不需要圆括号或方法参数。

属性

Web only?

描述

例子

permitAll

No

任何用户均可访问

access="permitAll"

denyAll

NO

任何用户均不可访问

access="denyAll"

anonymous

NO

匿名用户可访问

access="anonymous"

authenticated

NO

检查用户是否认证过

access="authenticated"

rememberMe

No

检查用户是否通过remember me 功能认证的

access="rememberMe"

fullyAuthenticated

No

检查用户是否通过提供完整的凭证信息来认证的

access="fullyAuthenticated"

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
《Spring Security 3》 【第二章】 Spring Security起步(3)
【第五章】Spring表达式语言 之 5.4在Bean定义中使用EL—跟我学spring3...
【框架】121:spring框架之IOC容器
Spring @Value 属性注入使用总结二
Spring认证中国教育管理中心-Spring Data MongoDB教程七
spring security 3.1配置过程从简单到复杂详细配置
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服