java Advice spring mvc http消息转换器
我试图建议spring http消息转换器,但我无法让它工作
@Pointcut("within(org.springframework.http.converter.xml.MarshallingHttpMessageConverter)")
public void converterPointcut() {
}
@Pointcut("execution(* *(..))")
public void converterMethodPointcut() {
}
@Around("converterPointcut() && converterMethodPointcut()")
public Object aroundConverter(ProceedingJoinPoint iJoinPoint) {
Object aProceed = null;
try {
aProceed = iJoinPoint.proceed();
} catch (Throwable anException) {
anException.printStackTrace();
}
return aProceed;
}
有什么问题吗
# 1 楼答案
a)使用
within
,您只是建议MarshallingHttpMessageConverter
类的方法,您确定这就是您想要的吗b)要编织一个库类,您需要set up{a2}
或者通过aspectj编译器运行spring JAR(哎哟,别这么做)。你们有装货时间安排吗c)定义无法使其工作:发生了什么,没有发生什么
更新:我认为您试图解决错误的问题。不要使用AspectJ,只需扩展类(none of the methods are final)和register the extended class as ^{}