栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Spring AOP和MVC订购方面

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Spring AOP和MVC订购方面

您不需要实现Ordered接口。

在Spring AOP中,您可以更轻松地完成工作。

@Aspect@Order(1)public class AspectA{  @Before("............")   public void doit() {}}@Aspect@Order(2)public class AspectB{  @Before(".............")  public void doit() {}}

更新:

@Aspect@Order(1)public class SpringAspect {    @Pointcut("within(com.vanilla.service.MyService+)")    public void businessLogicMethods(){}     @Around("businessLogicMethods()")     public Object profile(ProceedingJoinPoint pjp) throws Throwable {  System.out.println("running Advice #1"); Object output = pjp.proceed();         return output;     }}@Aspect@Order(2)public class SpringAspect2 {    @Pointcut("within(com.vanilla.service.MyService+)")    public void businessLogicMethods(){}     @Around("businessLogicMethods()")     public Object profile(ProceedingJoinPoint pjp) throws Throwable {  System.out.println("running Advice #2"); Object output = pjp.proceed();         return output;     }}

现在,应用程序上下文配置XML:

<context:annotation-config /><aop:aspectj-autoproxy />  <bean id="springAspect"  />    <bean id="springAspect2"  />

您需要通过以下方式启用AOP代理:

<aop:aspectj-autoproxy />

否则,将不会激活任何建议。

更新2:

我只是对此问题进行研究。

@order
注解仅适用于基于Spring的代理AOP(在我的示例中使用的是)。如果您使用的是编织文件,则应使用声明优先级选项。

更新3

  1. 我在您的代码中看不到任何建议,只是方面和切入点。
  2. 如果您的Advice类是:xyzSystemArchitecture

那么您需要将其配置为

<bean id="systemArchitecture"  />

我在您的代码中看不到它。

  1. “执行( com.jajah.StorageManager.HomeController。(..))”的目标是什么?可以用文字写吗?

无论如何。请在Facebook上给我留言,我将向您发送一个工作示例,该示例正是您要执行的操作。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/507333.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号