Filter获取方法的注解

使用Filter可以获取方法上的注解吗?
例如:

@RestController
@Slf4j
public class DemoController implements BaseController {

    @Autowired
    private DemoService demoService;

    @Delete
    @GetMapping("/get")
    public String get(@RequestParam String name) {
        log.info("get");
        final String hello = demoService.sayHello();
        return hello + ", " + name;
    }
}

DemoController中的get方法加了@Delete注解,使用Filter可以获取get方法是否加了@Delete注解吗?
使用Interceptor和Aspect的方式是可以获取到的,Filter呢?

阅读 5.4k
1 个回答

不能。

Filter 执行的时候还并未知道后面会由哪个 Controller、哪个 Action 处理请求,就更别提拿到注解了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进