@Aspect aop repeated execution

Some problems in the use of @Aspect:

  Because the recent system requirements want to record the operation log of the background administrator, such as what button was clicked, what operation was done, what parameters were passed in, and what results were returned, all of them wanted to be recorded, so Each method at the controller level needs to be intercepted.

So my first reaction is to face the aspect. There are many ways to implement it, and here I use the @Aspect annotation.
Record the problems that arise in the middle.
1. There is no cut to the aspect:
@AfterReturning(pointcut="execution(* com.admin.controller..*.*(..)))",
            returning="returnValue")
    public void afterOp(JoinPoint point, Object returnValue) {
        try {
            xxx;
            }
        } catch (Exception e) {
            logger.error("Record system administrator operation log exception: "+e);
        }
After the configuration is completed, it is found that after the corresponding controller layer method is executed, there is no jump Go to the corresponding method, and after a series of data review, the solution is as follows:
1. It is possible that the execution expression is incorrect. Pay attention to the package name, class name, method name, rules for entering parameters, etc.
2. The annotation is not enabled <aop:aspectj-autoproxy proxy-target-class="true"/>, (I read some blogs on the Internet that this needs to be configured in the springmvc configuration file, which has no effect in the spring configuration file )

2. Repeated execution of the method:
because I cut all the controller methods, so when I clicked on the query list page, I entered this method twice. Later, I looked at it because the @InitBinder annotation was used in the controller layer. It is mainly used to parse and bind page data, such as time format.
Solution:
Add the targer method to judge and filter out.

Because the project configuration and the framework used are different, the problems that may be encountered are also different, so it is only for reference

Guess you like

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