为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > Spring拦截器的简单例子

Spring拦截器的简单例子

2018-03-26 3页 doc 14KB 9阅读

用户头像

is_856983

暂无简介

举报
Spring拦截器的简单例子Spring拦截器的简单例子 Purview接口: package aop; public interface Purview{ void checkLogin(); } PurviesImpl类(Purview接口的实现类): package aop; public class PurviewImpl implements Purview{ public void checkLogin(){ System.out.println("This is check Login method!"); } } ...
Spring拦截器的简单例子
Spring拦截器的简单例子 Purview接口: package aop; public interface Purview{ void checkLogin(); } PurviesImpl类(Purview接口的实现类): package aop; public class PurviewImpl implements Purview{ public void checkLogin(){ System.out.println("This is check Login method!"); } } PurviewAdvice类(拦截器类): package aop; import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; public class PurviewAdvice implements MethodBeforeAdvice{ public void before(Methodarg0,Object[]arg1,Objectarg2) throws Throwable{ System.out.println("This is before method!"); } } Test类(测试类): package aop; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test{ public static void main(String[]args){ //TODO自动生成方法存根 ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml"); Purview purviewImpl=(Purview)ctx.getBean("purviewImpl"); purviewImpl.checkLogin(); } } applicationContext.xml(配置文件): .*checkLogin.* purviewImpl purviewAdvisor 程序运行结果为: This is before method! This is checkLogin method! 至此拦截器使用成功!
/
本文档为【Spring拦截器的简单例子】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索