简体   繁体   中英

create new spring annotation

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.

I am not sure if creating new annotations is what you really need. You could probably use Spring Security and its annotations. Please take a look here to see if it is what you are looking for.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM