Spring Security可以在Spring控制器方法上使用@PreAuthorize吗? [英] Can Spring Security use @PreAuthorize on Spring controllers methods?

查看:910
本文介绍了Spring Security可以在Spring控制器方法上使用@PreAuthorize吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Security可以在Spring控制器方法上使用 @PreAuthorize 吗?

Can Spring Security use @PreAuthorize on Spring controllers methods?

推荐答案

p>是的,它工作正常。

Yes, it works fine.

您需要< security:global-method-security pre-post-annotations =enabled/> ...- servlet.xml 中。它还需要 CGLIB代理,因此您的控制器不应该有接口,或者您应该使用 proxy-target-class = true

You need <security:global-method-security pre-post-annotations="enabled" /> in ...-servlet.xml. It also requires CGLIB proxies, so either your controllers shouldn't have interfaces, or you should use proxy-target-class = true.

这篇关于Spring Security可以在Spring控制器方法上使用@PreAuthorize吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆