main 方法调用是调用的是代理类
   public static void main(String[] args)
  {       ApplicationContext context=new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
       ILogin login=(ILogin)context.getBean("helloProxy");
       login.方法();
  }
  必须调用代理类,因为代理类加入了前置通知!

解决方案 »

  1.   

    ======================****************===================
    版主真情回复:
    部分的代码内容没有说明清楚,以上的项目采用的是SSH(Struts2+Spring+Hibernate)框架,ILogin该接口是由Action实现的!
    该action的代码如下:public class CustomerAction extends ActionSupport implements ILogin{
    //CustomerAction里面的public String findCustomer()方法需要进行用户登录判断,这个方法写在AOP接口里了。//调用AOP接口,实现登陆判断
    public void aopInterface() {
    CheckLogin bb = new CheckLogin();
    bb.islogin();}
    }
    applicationContext.xml里面的<ref local="customerAction"/> 指的就是这个ACTION
      

  2.   


    正解,调用代理类 >>
      

  3.   

    大家可以跟空上帖子关联起来看.
    http://topic.csdn.net/u/20090103/12/ea64b467-75f0-4dc1-b3a1-140bb5147c7a.html
      

  4.   

    要想在action之前执行通知的话,struts的action的配置文件的class应该是helloProxy
    如果验证登录的话,无需到spring层面,直接用struts2的拦截器即可,请看这里给你的回复http://topic.csdn.net/u/20090103/12/ea64b467-75f0-4dc1-b3a1-140bb5147c7a.html
      

  5.   

    执行时, 调用的为代理类 helloProxy 
      

  6.   

    看看我这个
     applicationContext.xml   <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="word" class="com.east.spring.aop.methodmid.Worker"/>
    <!--  閰嶅埗鍒囬潰-->
    <bean id="proxy" class="com.east.spring.aop.methodmid.MethodMidProxy"/>
    <bean id="before" class="com.east.spring.aop.methodmid.BeforeProxy"/>
    <bean id="after" class="com.east.spring.aop.methodmid.AfterProxy"/>
    <!-- 閰嶇疆浠g悊绫?-->
    <bean id="springProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
      <!-- 鎺ュ彛 -->
      <property name="interfaces">
         <value>com.east.spring.aop.methodmid.IWork</value>
      </property>
      <!-- 鐪熷疄鐨勪唬鐞嗙殑绫?-->
      <property name="target" ref="word"></property>
      <!-- 閰嶇疆鍒囬潰 -->
      <property name="interceptorNames">
        <list>
          <value>proxy</value>
          <value>before</value>
          <value>after</value>
        </list>
      </property>
    </bean>
    </beans>
    ---------------------------------------------------
    package com.east.spring.aop.methodmid;public interface IWork {
    public void doWork();
    }
    ---------------------------------------------------
    package com.east.spring.aop.methodmid;public class Worker implements IWork {
    public void doWork() {
    try{
    Thread.sleep(1000);
    }catch(Exception se){
    se.printStackTrace();
    }
     System.out.println(" this is Worker");
    }}
    ----------------------------------------------------
    package com.east.spring.aop.methodmid;import java.lang.reflect.Method;import org.springframework.aop.MethodBeforeAdvice;/**
     * 在方法调用这前调用其它的方法
     * @author Administrator
     *
     */
    public class BeforeProxy implements MethodBeforeAdvice{ public void before(Method method, Object[] value, Object target)
    throws Throwable {
    System.out.println("在方法调用这前调用其它的方法");
    Object result = method.invoke(target, value);

    }
     
    }
    -----------------------------------
    package com.east.spring.aop.methodmid;import org.springframework.beans.factory.BeanFactory;
    import org.springframework.context.support.ClassPathXmlApplicationContext;public class TestAop {
     public static void main(String[] args) {
    BeanFactory bf = new ClassPathXmlApplicationContext("applicationContext.xml");
    //springProxy是代理对像的ID
    IWork work = (IWork)bf.getBean("springProxy");
    work.doWork();
    }
    }
    --------------