Modify the parameters in the enhanced method using spring:aop

We all know that in the enhancement method, the incoming parameters can be obtained by using jp.getArgs()[index], but after the parameters are passed in, how to change their values?

Because what jp.getArgs()[index] gets is only a backup of the data, so modify jp.getArgs()[index] = Null; the value obtained in other enhancement methods does not change after modification

So this method can be used:

Object[] args = jp.getArgs();

args[0] = null;

args[1] = null;

Then call the jp.proceed(args) method in the surround enhancement (Around) to modify the incoming parameters.

This should be equivalent to re-passing a parameter into it


Guess you like

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