zoukankan      html  css  js  c++  java
  • springmvc 开涛 拦截器

    拦截器有三个方法:preHandle, postHandle, afterCompletion

    ***-servlet.xml

    <bean name="/test" class="cn.javass.chapter5.web.controller.TestController"/>
    <bean id="handlerInterceptor1" 
    class="cn.javass.chapter5.web.interceptor.HandlerInterceptor1"/>
    <bean id="handlerInterceptor2" 
    class="cn.javass.chapter5.web.interceptor.HandlerInterceptor2"/>
    //是HandlerMapping接口的实现类
    <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
        <property name="interceptors">
            <list>
               <ref bean="handlerInterceptor1"/>
              <ref bean="handlerInterceptor2"/>
            </list>
        </property>
    </bean>
    

    中断流程

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("===========HandlerInterceptor1 preHandle");
       response.getWriter().print("break");//流程中断的话需要我们进行响应的处理
        return false;//返回false表示流程中断    
    }
    

    性能监控,登陆检测 具体细节不太清楚。

  • 相关阅读:
    PHP安装linux
    nginx 安装
    Redis安装
    linux启动http服务
    收藏的有用的网页
    laravel框架部署后有用命令
    .net 报错access to the path c: empimagefilesmsc_cntr_0.txt is denied
    oracle 触发器
    学习Auxre记录
    mysql数据库索引
  • 原文地址:https://www.cnblogs.com/wang-jing/p/4570206.html
Copyright © 2011-2022 走看看