zoukankan      html  css  js  c++  java
  • struts2 MessageStoreInterceptor 拦截器的使用

    MessageStoreInterceptor 拦截器可以把和该 Action 相关的 messages, errors 和 field errors(下称 "消息") 保存到 session 中(默认放在 Action 中, 而 Action 在 request 中). 以使可以跨请求访问 messages, errors 和 field errors.

    从文档上知道 operationMode 的合法取值有: NONE, STORE, RETRIEVE 和 AUTOMATIC. 其中 NONE 为默认值.

             ①. STORE: MessageStoreInterceptor 拦截器会把 "消息" 放入 session 域中.

             ②. RETRIEVE: MessageStoreInterceptor 拦截器会把 "消息" 从 session 中取出来, 放入 Action 中.       

             ③. AUTOMATIC: MessageStoreInterceptor 拦截器会把 "消息" 从 session 中取出来, 放入 Action 中.  而且若响应结果的类型的 redirect, Action 中的 "消息" 会被放入 session 中.               

             ④. NONE: 什么都不做.

    MessageStoreInterceptor 拦截器能保证 actionMessage 在 redirect 后不会丢失.  struts.xml 文件的部分配置如下:

    <interceptors>
    <interceptor-stack name="storeMessage">
    <interceptor-ref name="defaultStack" />
    <interceptor-ref name="store">
    <param name="operationMode">AUTOMATIC</param>
    </interceptor-ref>
    </interceptor-stack>
    </interceptors>

    <default-interceptor-ref name="storeMessage" />

    使用的时候需要把type参数设置为redirect

    <action name="action" class="Action">
    <result name="success" type="redirect">NextAction</result>
    </action>

  • 相关阅读:
    Python 实现AEC CBC 加密解密方式
    redis 发布订阅方法与缺陷
    python paramiko 传输下载文件
    Redis 配置文件
    Redis 命令
    window11 | 虚拟机vmWare安装windows11
    十万个为什么 | 文化001-为什么猜灯谜又叫做打灯谜
    ffmpeg | 常用命令使用
    ffmpeg | 常用命令使用
    Adobe系列 | Animate(01)-软件安装
  • 原文地址:https://www.cnblogs.com/akatuki/p/4039826.html
Copyright © 2011-2022 走看看