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

    • 获取作用域对象
      String name="";
      HttpServletRequest request = ServletActionContext.getRequest();
      request.setAttribute("info", name);
      HttpServletResponse response = ServletActionContext.getResponse();   
      HttpSession session = request.getSession();
      ServletContext application = ServletActionContext.getServletContext();
    • 拦截器
      • 编写拦截器
        • 声明一个类,让这个类继承(implements) Interceptor接口;
      • 声明拦截器
        <interceptors>
               <interceptor name="testInt_register" class="action.TestInt"></interceptor> <!-- 声明拦截器 -->
        </interceptors>
      • 映射拦截器
        <interceptor-ref name="testInt_register"></interceptor-ref> <!-- 映射拦截器 -->
      • 多个拦截器
        • 多个拦截器映射的顺序就是调用的顺序;
          <struts>
                <package name="struts02" extends="struts-default">
                     <interceptors>
                           <interceptor name="testInt_register" class="action.TestInt"></interceptor> <!-- 声明拦截器 -->
                           <interceptor name="testInt_reg" class="action.TestInt01"></interceptor>
                     </interceptors>
                     <action name="register" class="action.RegisterAction" method="register">
                     
                           <interceptor-ref name="testInt_reg"></interceptor-ref>
                           <interceptor-ref name="testInt_register"></interceptor-ref> <!-- 映射拦截器 -->
                           
                           <result>registerSuccess.jsp</result>
                     </action>
                </package>
          </struts>
           配置自定义拦截器后,默认拦截器全部失效,需要在action后加入:
          <interceptor-ref name="basicStack"></interceptor-ref>
      • 拦截器的堆栈
        <interceptors>
               <interceptor name="testInt_register" class="action.TestInt"></interceptor> <!-- 声明拦截器 -->
               <interceptor name="testInt_reg" class="action.TestInt01"></interceptor>
               <!-- 拦截器堆栈 -->
               <interceptor-stack name="mystack">
                      <interceptor-ref name="testInt_reg"></interceptor-ref> <!-- 映射拦截器 -->
                      <interceptor-ref name="testInt_register"></interceptor-ref>
                       <interceptor-ref name="basicStack"></interceptor-ref>
               </interceptor-stack>  
        </interceptors>
             
     
     
  • 相关阅读:
    AndroidManifest.xml 注册服务
    Android App消息通知机制【转】
    [转]android之Apache Http——向服务器发送请求的同时发送参数
    [转][WCF REST] 帮助页面与自动消息格式(JSON/XML)选择
    android新手上路之----解决android模拟器不能上网的问题
    mysqli类实例
    MYSQL视图
    jsp传递url地址里带有&的无法接收的解决方法
    Oracle序列归0的2种方法
    使用连接池管理数据库连接
  • 原文地址:https://www.cnblogs.com/wq-code/p/8360993.html
Copyright © 2011-2022 走看看