zoukankan      html  css  js  c++  java
  • ActionContextCleanUp的作用

    延长action中属性的生命周期,包括自定义属性,以便在jsp页面中进行访问,让actionContextcleanup过滤器来清除属性,不让action自己清除。

    为了使用WebWork,我们只需要在web.xml配置FilterDispatcher一个过滤器即可,阅读一下FilterDispatcher的JavaDoc和源码,我们可以看到它调用了:

    finally
    {
    ActionContextCleanUp.cleanUp(req);
    }

    在ActionContextCleanUp中,有这样的代码:

    req.setAttribute(CLEANUP_PRESENT, Boolean.TRUE);

    如果FilterDispatcher检测到这个属性,就不会清除ActionContext中的内容了,而由ActionContextCleanUp后续的代码来清除,保证了一系列的Filter访问正确的ActionContext.

    文档中提到,如果用到SiteMesh的Filter或者其他类似Filter,那么设置顺序是:

    ActionContextCleanUp filter
    SiteMesh filter
    FilterDispatcher
    所以最后我们的web.xml应该类似这样:

    <filter>
    <filter-name>ActionContextCleanUp</filter-name>
    <filter-class>com.opensymphony.webwork.dispatcher.ActionContextCleanUp</filter-class>
    </filter>

    <filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>com.opensymphony.webwork.sitemesh.FreeMarkerPageFilter</filter-class>
    </filter>

    <filter>
    <filter-name>webwork</filter-name>
    <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>ActionContextCleanUp</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
    <filter-name>webwork</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

  • 相关阅读:
    人一生要去的100个地方(世界)
    数据仓库相关书籍
    学理财要看的书籍
    数仓设计 Building the Data Warehouse
    Google Cloud 安装java
    Google Cloud install python3 (in CentOS)
    SyntaxError: Non-ASCII character 'xe5' in file test23.py on line 2, but no encoding declared;
    CentOS 安装7z
    CentOS 安装 MySQL
    复杂迭代代码分析
  • 原文地址:https://www.cnblogs.com/langtianya/p/3011094.html
Copyright © 2011-2022 走看看