创建新的 spring 注释 [英] create new spring annotation

查看:24
本文介绍了创建新的 spring 注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Spring 中开发一个应用程序,它在控制器中有许多方法,并使用 @RequestMapping 映射到各种 URL.

某些用户角色可以访问其中一些方法(以及 url),而其他用户则无法访问.我可以创建注释,并注释这些方法,以便只有特权用户才能访问正确的方法,而不能访问其他人吗?

提前致谢.

解决方案

您可以使用 Spring Security 及其注解,限制对某些方法的访问.这个博客文章展示了所使用的注释的一些特性使用 Spring Security 3.

查看此问答,了解如何构建自己的注释在春季安全之上.<​​/p>

另见Spring Security 3.1,基于表达式的访问控制一章.

I'm developing an application in Spring which has numerous methods in the controller, and are mapped to various URL using @RequestMapping.

Some of these methods (and hence url) are accessible to some user roles, and not to others. Can I create annotations, and annotate these methods so that only privileged users have access to right methods, while not to the others?

Thanks in advance.

解决方案

You can use Spring Security and its annotations, restrict access to some methods. This Blog post show some features of annotations used with Spring Security 3.

Have a look at this question and answer, to see how you build your own annotations on top of spring security.

See also the documentation of Spring Security 3.1, Chapter Expression-Based Access Control.

这篇关于创建新的 spring 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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