什么是覆盖参数的AspectJ声明性语法

之前已经使用注释语法对此进行了回答: Aspectj覆盖方法的参数

但我无法弄清楚如何使用AspectJ声明性语法。 以下应该在方法中的每个字符串前添加“Poop”,但它不会。

public aspect UserInputSanitizerAdvisor { pointcut unSafeString() : execution(@RequestMapping * * (..)); Object around() : unSafeString() { //thisJoinPoint.getArgs(); //proceed(); System.out.println("I'm Around"); Object[] args = thisJoinPoint.getArgs(); if (args != null) { for (int i = 0; i < args.length; i++) { Object o = args[i]; if (o != null && o instanceof String) { String s = (String) o; args[i] = "poop: " + s; } } } return proceed(); } } 

我无法弄清楚如何给出“继续()”所有的论点。

我得到了注释版本:

 @SuppressWarnings("unused") @Aspect public class UserInputSanitizerAdivsor { @Around("execution(@RequestMapping * * (..))") public Object check(final ProceedingJoinPoint jp) throws Throwable { Object[] args = jp.getArgs(); if (args != null) { for (int i = 0; i < args.length; i++) { Object o = args[i]; if (o != null && o instanceof String) { String s = (String) o; args[i] = UserInputSanitizer.sanitize(s); } } } return jp.proceed(args); } } 

现在我对所有的Spring MVC控制器都有XSS保护。 我希望得到aspectJ语法。

return thisJoinPoint.proceed(args); 做你想要的?