程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Spring Aspectj @所有其余方法之前大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Spring Aspectj @所有其余方法之前?

开发过程中遇到Spring Aspectj @所有其余方法之前的问题如何解决?下面主要结合日常开发的经验,给出你关于Spring Aspectj @所有其余方法之前的解决方法建议,希望对你解决Spring Aspectj @所有其余方法之前有所启发或帮助;

我发现这句法这里对我的作品!

@pointcut("execution(@(@org.springframework.web.bind.Annotation.requestMapPing *) * *(..))")
public voID requestMapPingAnnotations() { }

我也可以全部列出

@pointcut("within(aa.bb.*.rest..*)  && @within(org.springframework.web.bind.Annotation.RestController)")
public voID restControllers() {}

@pointcut("@Annotation(org.springframework.web.bind.Annotation.requestMapPing) " +
    "|| @Annotation(org.springframework.web.bind.Annotation.GetMapPing)" +
    "|| @Annotation(org.springframework.web.bind.Annotation.PostMapPing)" +
    "|| @Annotation(org.springframework.web.bind.Annotation.PatchMapPing)" +
    "|| @Annotation(org.springframework.web.bind.Annotation.PutMapPing)" +
    "|| @Annotation(org.springframework.web.bind.Annotation.deleteMapPing)"
)
public voID mapPingAnnotations() {}

@pointcut("execution(@(@org.springframework.web.bind.Annotation.requestMapPing *) * *(..))")
public voID requestMapPingAnnotations() { }

@Before("restControllers() && requestMapPingAnnotations()")
public voID onExecute(JoinPoint jp) {}

解决方法

在春季介绍之前@GetMapping,我们只关心一个注释@requestMapping,因此,此方面有效

@Before("within(aa.bb.*.rest..*) && execution(public * *(..)) && @within(org.springframework.web.bind.Annotation.RestController) && @Annotation(org.springframework.web.bind.Annotation.requestMapping)")

但是,在我们可以使用@GetMapping之后@PostMapping,这一点不起作用,但是这些注释具有meta注释@requestMapping

有什么办法可以轻松拦截所有@requestMapping/ @{Get,Post,Put,Patch,..}Mapping吗?

大佬总结

以上是大佬教程为你收集整理的Spring Aspectj @所有其余方法之前全部内容,希望文章能够帮你解决Spring Aspectj @所有其余方法之前所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。