切入点"""不适用于控制器中的受保护方法

时间:2017-08-23 20:02:59

标签: java spring spring-mvc aop spring-aop

这是我的代码:

控制器类

@controller 
public class TrendController extends MyController{

@RequestMapping(method= RequestMethod.POST, value = "/trend")
public ModelAndView myReq(@RequestBody body, HttpHeaders hdr){
return super.myReq(body,hdr)
   }
}

MyController类

 public abstract class MyController implements ApplicationContextAware{

    protected ModelAndView myReq(@RequestBody body, HttpHeaders hdr){
    MyReqType req = null;

    req = unmrsl(body,hdr);

    }

protected MyReqType unmrsl(@RequestBody body, HttpHeaders hdr){
MyReqType  request = null;
.
.
.
return request;
}

}

AOP配置:

我在myReq.xml中添加了我的切入点表达

<bean id="myAspect" class = com.abc.xyz.aop.myInterceptor/>

<aop:config>
<aop:aspect ref="myAspect">
<aop pointcut id="myPrReq"
expression="execution(* com.abc.xyz.controllers.MyController.unmrsl(..)"/>
<aop:after pointcut-ref="myPrReq" method="myTestMthd"/>

现在..我已经在com.abc.xyz.aop.myInterceptor.Java中编写了myTestMthd,它假设在MyController中执行unmrsl方法之后在myTestMthd中点击我的逻辑。但它没有按预期工作。

com.abc.xyz.aop.myInterceptor.Java

public class myInterceptor{

public void myTestMthd(JoinPoint call){
.
.
mylogic
.
.
  }
}

0 个答案:

没有答案