From:http://stackoverflow.com/questions/6632982/how-to-create-custom-methods-for-use-in-spring-security-expression-language-anno

None of the mentioned techniques will work anymore. It seems as though Spring has gone through great lengths to prevent users from overriding the SecurityExpressionRoot. Instead, create a bean like this:

@Component("mySecurityService")publicclassMySecurityService{publicboolean hasPermission(String key){returntrue;}}

Then do something like this in your jsp:

<sec:authorize access="@mySecurityService.hasPermission('special')"><input type="button" value="Special Button"/></sec:authorize>

Or annotate a method:

@PreAuthorize("@mySecurityService.hasPermission('special')")publicvoid doSpecialStuff(){...}

And remember: if you are using Spring and you have to solve a problem by extending classes, overriding methods, implementing interfaces, etc... then you're probably doing something wrong. It's all annotations and xml, that's why we love Spring so much and not (old versions of) EJB.

How to create custom methods for use in spring security expression language annotations的更多相关文章

  1. How to Create Custom Filters in AngularJs

    http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction Filter ...

  2. create custom launcher icon 细节介绍

    create custom launcher icon 是创建你的Android app的图标 点击下一步的时候,出现的界面就是创建你的Android的图标 Foreground: ” Foregro ...

  3. [转]How to Create Custom Filters in AngularJs

    本文转自:http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction F ...

  4. How to: Create Custom Configuration Sections Using ConfigurationSection

    https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...

  5. 3.2Adding custom methods to mappers(在映射器中添加自定义方法)

    3.2Adding custom methods to mappers(在映射器中添加自定义方法) 有些情况下,我们需要实现一些MapStruct无法直接自动生成的复杂类型间映射.一种方式是复用其他已 ...

  6. Linux shell create file methods

    Linux shell create file methods touch, cat, echo, EOF touch $ touch file.py $ touch file1.txt file2. ...

  7. java中如何创建自定义异常Create Custom Exception

    9.创建自定义异常 Create Custom Exception 马克-to-win:我们可以创建自己的异常:checked或unchecked异常都可以, 规则如前面我们所介绍,反正如果是chec ...

  8. Spring security 3.1 +JSF 2.0 . problem with annotating methods in ManagedBeans?

    Hy .What i am trying to do is to integrate Spring security with a Jsf+spring IOC +hibernate applicat ...

  9. php foreach 报 “Cannot create references to elements of a temporary array expression”

    今天在项目中用php foreach数据库查询结果时,为了方便没有判断数据是否存在,直接用(array)强制转换数据时,刚开始网页始终打不开,就报502,一头懵,突然间php报“Cannot crea ...

随机推荐

  1. memcached缓存雪崩现象及解决办法

    1)什么是缓存雪崩?场景:一个访问很大的文章(论坛之类)的网站,使用memcached缓存用户查询过的文章.设置的缓存过期时间为6小时,所以没过6小时,缓存就会失效并重建一遍 问题:过六小时时,一部分 ...

  2. SQL语句方法语法总结(三)

    1.时间相关的操作 月份.星期.日期.时间格式转换.第几周 ,'2014-4-1') as '时间间隔', --在所给时间上加上时间间隔,转换成DATETIME DATEDIFF(DAY,'2014- ...

  3. 分布式网站架构后续:zookeeper技术浅析

    Zookeeper是hadoop的一个子项目,虽然源自hadoop,但是我发现zookeeper脱离hadoop的范畴开发分布式框架的运用 越来越多.今天我想谈谈zookeeper,本文不谈如何使用z ...

  4. KVM虚拟化技术简介

    kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中.它使用Linux自身的调度器进行管理,所 ...

  5. 【转】RTSP实例解析

    原文网址:http://www.cnblogs.com/qq78292959/archive/2010/08/12/2077039.html. 核心提示:rtsp简介(ZT) Real Time St ...

  6. 【转】搭建Python的Eclipse开发环境之安装PyDev插件--离线安装

    原文网址:http://blog.csdn.net/wangpingfang/article/details/7181223 使用update site安装pydev插件 注意:该安装指南针对ecli ...

  7. anything vs everything

    everything多用于肯定而anything多用于否定和疑问语气 anything 1) 任何事情/东西,可以用在肯定句/否定句/疑问句中.如:You can take anything you ...

  8. Dev gridControl z

    Dev gridControl 添加表标题 1.OptionsView ->ShowViewCaption = True 2.ViewCaption = "标题" Dev g ...

  9. Linux基本命令(6)线上查询的命令

    线上查询的命令 命令 功能 man 查询和解释一个命令的使用方法,以及这个命令的说明事项 locate 定位文件和目录 whatis 寻找某个命令的含义 6.1 man命令 man命令用来查询和解释一 ...

  10. JavaScript对象(窗口对象 定时器对象 )

    1:窗口时间 confirm(str):确认对话框,确认返回trun,取消返回false,但是必须要有两个return:不然就算按下取消也会提交 第一个return:用于保证确认按钮运行 <sc ...