Struts2中的拦截器
来源:互联网 发布:java使用md5加密解密 编辑:程序博客网 时间:2024/05/22 00:07
<!-- 配置拦截器栈 -->
<interceptor-stack name="myStack">
<interceptor-ref name="myInterceptor2" ><param name="excludeMethods">login</param></interceptor-ref><interceptor-ref name="defaultStack" /></interceptor-stack></interceptors>
Struts2 中的拦截器 是AOP的一直体现。(AOP是面向切面编程)。它与过滤器是有些不同,这里面的拦截器是针对action的,而过滤器,看你配置是拦截什么它就过滤什么,一般过滤器都配置为 "/*"。
我们自定义一个拦截器有三种方式,一是:实现Interceptor接口,实现里面的三个方法。二是,继承一个AbstractInterceptor这个抽象类,我觉得它就像是个适配器类。我们只要实现它里面的intercept() 这个方法就好了。三是,继承一个MethodFilterInterceptor这个抽象类,实现其中的doIntercept() 方法,这中方式可以实现拦截某个action中的某些方法,不拦截某些方法。做法就是在配置的时候呢,传递两个参数:1 : excludeMethod 这个是排除某些方法,而拦截其他的方法。2. includeMethod ,这个是拦截指定的方法。
注:需要注意的是,当我们自定义拦截器后,struts2中的默认拦截器不再执行,需要我们手动加入默认拦截器。
阅读全文
0 0
- struts2中的拦截器
- Struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- struts2中的拦截器
- Struts2中的拦截器
- struts2中的拦截器
- Struts2中的拦截器
- Struts2中的拦截器
- struts2中的拦截器
- Struts2中的拦截器
- Struts2中的拦截器
- 关于struts2中的拦截器
- 关于Spring
- 算法提高 ADV-134 校门外的树
- Sublime Text 3 快捷键
- iOS学习笔记-094.彩票09——隐藏底部tabar和统一设置返回按钮
- 欧拉函数的一道练习题(附加容斥做法)
- Struts2中的拦截器
- python nonlocal关键字
- Python基础
- Python3[爬虫实战] 爬虫之scrapy爬取爱上程序网存MongoDB(android模块)
- python 知识点
- PostgreSQL插件开发踩坑之路1
- win32窗口程序-------3、位图及去除背景色
- (三)创建功能模块
- c_day05 联合体-枚举