我正在尝试建议 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;
}
这里有什么问题吗?
最佳答案
a) 使用 within
,您仅建议 MarshallingHttpMessageConverter
类的方法,您确定这就是您想要的吗?
b) 要编写库类,您需要 set up load time weaving 或者通过aspectj编译器运行spring jar(哎哟,不要这样做)。您是否设置了加载时间编织?
c) 定义无法让它工作:发生什么,不发生什么?
<小时/>更新:我认为您正在尝试解决错误的问题。不要使用 AspectJ,只需扩展类 ( none of the methods are final ) 和 register the extended class as HttpMessageConverter
关于java - 建议 spring mvc http 消息转换器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5716943/