spring - AOP annotations for spring

How to get the parameters of the target method:

    Requirements: If you want to get the parameters of the target method and record them.

                             

                        

Get the target object:

    target(t) The purpose of target is to get the target object

                             

                             

Get the annotation on the get method:

    Requirement: How to get annotations on methods through pointcut expressions

                             

                            


Aspect annotation

    1- Turn on Aspect Annotation

                                 

    2- Define the aspect - @Aspect

                                                

    3. Define the entry point - two ways

            1. Empty method

                *1* Create an empty method in the aspect and annotate it with @Pointcut(value=" pointcut expression ")

                    @Pointcut(value=" pointcut expression ")

@Pointcut(value="pointcut expression")
public void poincut(){}//empty method

                *2* Bind the pointcut in the advice annotation:

                    @Before(value="poincut() pointcut empty method name ")

                             

 

            2. Define inside the notification

                @Before(value="execution() match expression ")

         Note: This method is relatively simple, so that the pointcut only acts on this method

                         


    4. Define Notifications

        @Before // before

        @Around // Around

        @AfterReturning // After

        @AfterThrowing // Exception

        @After // final

 

    5. Get the parameters of the target method in the annotation

        Note: If you want to get parameters in the configuration file, you must add  and, in the annotation, if you want to get parameters, you must add &&

        1- Get parameters by empty method:

                         

 

        2- Define inside the notification

                         

                        Note: In addition to special reasons, it is recommended to use the internal definition method, which is also used the most.

 

    6. Post notification return value problem:

                         

   

 7. Exception notification return value problem

                         


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325519592&siteId=291194637