Spring MVC如何添加自定义注解

0
HTML Spring MVC C/C++ Go 27220 次浏览

Can anyone explain what I need to do to implement my own annotation that would add functionality to my web requests?

For example:

@Controller public class MyController { 
    @RequestMapping("/abc") 
    @RequiresSomeSpecialHandling 
    public void handleSecureRequest() { 
    } } 

Here @RequiresSomeSpecialHandling would be my own annotation that causes some special work to be done before or after the given web request /abc.

I know that on a very high level I would need to write a bean post processor, scan classes for my annotations, and inject custom mvc interceptors when needed. But are there any shortcuts to simplify this task? Especially for the two examples above.

Thanks in advance,

Spring框架介绍

Can anyone explain what I need to do to implement my own annotation that would add functionality to my web requests?

For example:

@Controller public class MyController { 
    @RequestMapping("/abc") 
    @RequiresSomeSpecialHandling 
    public void handleSecureRequest() { 
    } } 

Here @RequiresSomeSpecialHandling would be my own annotation that causes some special work to be done before or after the given web request /abc.

I know that on a very high level I would need to write a bean post processor, scan classes for my annotations, and inject custom mvc interceptors when needed. But are there any shortcuts to simplify this task? Especially for the two examples above.

Thanks in advance,
http://luju.me/spring/reference/overview.html

请尽量让自己的答案能够对别人有帮助

6个答案

默认排序 按投票排序