| ApplicationContext.xml的定义: <beans><bean id="loginInterceptor" class="com.dragon.Advice.LoginInterceptor"></bean>
 <bean id="loginTarget" class="com.dragon.study.Impl.LoginImpl"></bean>
 <bean id="login" class="org.springframework.aop.framework.ProxyFactoryBean">
 <property name="proxyInterfaces">
 <value>com.dragon.study.ILogin</value>
 </property>
 <property name="interceptorNames">
 <list>
 <value>loginInterceptor</value>
 </list>
 </property>
 <property name="target">
 <ref bean="loginTarget"/>
 </property>
 </bean>
 </beans>
 
 
 
 
 OK,以上就是所有代码,下面做一个测试类: Test类定义: 程序代码:  package com;  import java.io.*; import org.springframework.context.ApplicationContext;import org.springframework.context.support.FileSystemXmlApplicationContext;
 import com.dragon.study.ILogin; public class Test {public static void main(String[] args) throws IOException {
 ApplicationContext ctx = new FileSystemXmlApplicationContext("applicationContext.xml");
 ILogin login = (ILogin)ctx.getBean("login");
 login.login("flash"); //用户为flash是正确用户,否则是错误的
 }
 }
 
         
 说明:本教程来源互联网或网友上传或出版商,仅为学习研究或媒体推广,wanshiok.com不保证资料的完整性。
 
  2/2   首页 上一页 1 2 |