美文网首页
[Struts2]13-方法拦截器

[Struts2]13-方法拦截器

作者: 我相信你爱过gg | 来源:发表于2017-05-07 20:24 被阅读14次

前面说的拦截器,是拦截整个Action的,但是如我们只想拦截Action中的某个方法,那么就需要使用方法拦截器。使用方法拦截器需要继承MethodFilterInterceptor类。代码如下

public class asd extends MethodFilterInterceptor {  
    @Override  
    protected String doIntercept(ActionInvocation actionInvocation) throws Exception {  
        return null;  
    }  
}  

struts.xml配置文件中配置方法拦截器

<package name="s" namespace="/" extends="struts-default">  
  
        <interceptors>  
            <interceptor name="" class="">  
                <param name="includeMethods">list</param>  
            </interceptor>  
        </interceptors>  
          
        <action name="" method="">  
              
        </action>  
   
</package>  

有两个参数,一个设置被拦截方法(includeMethods),另一个设置不被拦截方法(excludeMethods),多个方法是用逗号分隔。

注意:在配置action元素的时候一定要使用method属性,因为它是通过这个属性进行拦截的。

相关文章

  • Struts2拦截器登录验证

    Struts2拦截器 Struts2拦截器的概念和Spring Mvc拦截器一样。 Struts2拦截器是在访问某...

  • [Struts2]13-方法拦截器

    前面说的拦截器,是拦截整个Action的,但是如我们只想拦截Action中的某个方法,那么就需要使用方法拦截器。使...

  • struts2 拦截器介绍

    1.Interceptor介绍 拦截器(Intercepter):拦截器是struts2的核心,struts2的众...

  • Struts框架笔记04_拦截器_标签库

    1. Struts2的拦截器 1.1 拦截器概述 拦截器,在AOP中用于在某个方法或某个字段被访问之前,进行拦截然...

  • struts2实验5:struts2 拦截器

    layout: post title: struts2实验5:struts2 拦截器 categories: S...

  • struts2 自定义拦截器

    一、为什么要自定义拦截器 在struts2里面有很多拦截器,这些拦截器是struts2封装的功能,但是在实际开发中...

  • Struts2学习笔记(第三天)

    国际化 拦截器(interceptor) struts2中怎样使用拦截器 分析拦截器原理 关于intercepto...

  • 拦截器

    struts2中的大部分核心功能都是通过拦截器来实现的,诸如数据校验,类型转换,数据转移。拦截器方法在Action...

  • 拦截器

    拦截器的概述: 1、struts2是框架,封装了很多的功能,struts2里面封装的功能都是在拦截器里面。2、st...

  • SSH框架之Struts2的拦截器(四)

    第一节:Struts2的拦截器 1.1 拦截器的概述: 拦截器,在AOP(Aspect - Oriented Pr...

网友评论

      本文标题:[Struts2]13-方法拦截器

      本文链接:https://www.haomeiwen.com/subject/zokptxtx.html