有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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) 个答案

  1. # 1 楼答案

    a)使用within,您只是建议MarshallingHttpMessageConverter类的方法,您确定这就是您想要的吗

    b)要编织一个库类,您需要set up{a2}或者通过aspectj编译器运行spring JAR(哎哟,别这么做)。你们有装货时间安排吗

    c)定义无法使其工作:发生了什么,没有发生什么


    更新:我认为您试图解决错误的问题。不要使用AspectJ,只需扩展类(none of the methods are final)和register the extended class as ^{}