建议 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;
}
这里有什么问题吗?
I am trying to advice spring http message converter but, I can't get it to work.
@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;
}
Anything wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
a) 使用
within
,您仅建议MarshallingHttpMessageConverter
类的方法,您确定这就是您想要的吗?b)要编织一个库类,您需要 设置 加载时间编织
或者通过aspectj编译器运行spring jar(哎哟,不要这样做)。您是否设置了加载时间编织?c) 定义无法让它工作:发生了什么,没有发生什么?
更新:我认为您正在尝试解决错误的问题。不要使用 AspectJ,只需扩展该类 (没有一个方法是最终)和将扩展类注册为
HttpMessageConverter
a) using
within
, you are only advising the Methods of theMarshallingHttpMessageConverter
class, are you sure that's what you want?b) to weave a library class you need to either set up load time weaving
or run the spring jars through the aspectj compiler (ouch, don't do that). Do you have load time weaving set up?c) define can't get it to work: what happens, what doesn't happen?
Update: I think you are trying to solve the wrong problem. Don't use AspectJ, just extend the class (none of the methods are final) and register the extended class as
HttpMessageConverter