zoukankan      html  css  js  c++  java
  • 拦截器 interceptor

    一、常用拦截器

      Model Driven Interceptor 将getModel 结果放在值栈 ValueStack

      i18n Interceptor   国际化语言

      FileUpload ~ 文件上传

      Logger ~ 日志拦截

      Parameters ~  将请求参数设置到Action 中

      Validation  ~   验证数据

      Chaining Interceptor   结果类型

    二、参数(excludeMethods / includeMethods)

      1. 当 全局、局部 中param同为excludeMethods / includeMethods , 局部中的有效。

      2. 当 全局、局部 中param 不同时,以includeMethods 有效。

      3. 不指定时,默认includeMethods 方法。

    三、xml 中应用

      配置 的defaultStack拦截器栈  会默认应用到每一个action 上。

      在已定义全局的 defaultInterceptor 时, 可用defaultStack 让全局的配置失效。

    四、自定义 拦截器

      1、定义一个继承 AbstractInterceptor 的类。

      2、在 Struts.xml  中注册

      3、 在需要使用的 Action中应用

    五、Interceptor 接口

      1、 init() :在拦截器类被创建之后,在对Action镜像拦截之前调用,相当于一个 post-constructor 方法。

      2、  destroy():

      3、intercept(ActionInvocation invoction) {

        // action 前 可执行操作

        invocation.invoke() ;

        // action 后 可执行操作

      return “sucess”;

       

  • 相关阅读:
    Office2010中功能强大的图片背景删除工具
    ArcGIS 缓冲区单位转换问题
    ArcGIS Server 优化
    SQLSERVER 三值逻辑
    SQLSERVER 重置自增列
    ArcGIS 基于AO 实现的经纬度定位
    AO连接ArcGIS server 超时问题
    MySQL 1064 错误
    Socket 请求http 汉字编码问题
    Navicat创建存储过程
  • 原文地址:https://www.cnblogs.com/mobaids/p/10633775.html
Copyright © 2011-2022 走看看