【发布时间】:2012-04-12 23:02:50
【问题描述】:
我正在尝试通过 AOP 将标头添加到控制器响应中,但我不确定如何访问控制器或控制器的响应。
我该怎么做?
这是我当前的注释:
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.METHOD, ElementType.TYPE, ElementType.FIELD])
public @interface NoCaching {
}
这是我目前的方面:
@Aspect
@Component("noCachingAspect")
class NoCachingAspect {
@Pointcut("@annotation(com.grailsrocks.cacheheaders.NoCaching)")
public void nameDoesntMatter() {
}
@Before("com.grailsrocks.cacheheaders.NoCachingAspect.nameDoesntMatter()")
public void beforeMethod(JoinPoint joinPoint) throws Throwable {
println 'hellowoeijf'
}
}
这是我使用注释的方式:
@NoCaching
def annotations(){
println 'bar'
}
如何访问注解所针对的控制器以修改响应对象?
【问题讨论】:
标签: spring grails groovy aop spring-aop