springmvc 拦截器

拦截器实现

/*
 * AllInterceptor.java    1.0  2017-8-18
 *
 * 
 * 
 */


package com.zr.interceptor;


import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;


/**
 * [关于类内容的描述]
 * 
 * @author 
 * @version 1.0
 * 
 *          变更履历:
 *          v1.0 2017-8-18 mnt115 初版
 */
public class AllInterceptor implements WebRequestInterceptor {


    @Override
    public void afterCompletion(WebRequest arg0, Exception arg1) throws Exception {
        // TODO Auto-generated method stub
        System.out.println("AllInterceptor after");
    }


    @Override
    public void postHandle(WebRequest arg0, ModelMap arg1) throws Exception {
        // TODO Auto-generated method stub
        System.out.println("AllInterceptor in");
    }


    @Override
    public void preHandle(WebRequest arg0) throws Exception {
        // TODO Auto-generated method stub
        System.out.println("AllInterceptor befor");
    }


}

 

xml 文件配置 支持mvc标签

  xmlns:mvc="http://www.springframework.org/schema/mvc"  

 http://www.springframework.org/schema/mvc  
          http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

使用mvc标签配置拦截器

 
     
         
         
         
   

 

你可能感兴趣的:(springmvc 拦截器)