MyInterceptor.java 1.1 KB
Newer Older
Q
qinyingjie 已提交
1 2
package com.kwan.springbootkwan.config;

3
import lombok.extern.slf4j.Slf4j;
Q
qinyingjie 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义拦截器
 *
 * @author : qinyingjie
 * @version : 2.2.0
 * @date : 2022/12/19 16:14
 */
17
@Slf4j
Q
qinyingjie 已提交
18 19 20
public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
21
        log.info("MyInterceptor>>>>>>>>>preHandle");
Q
qinyingjie 已提交
22 23 24 25 26
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
27
        log.info("MyInterceptor>>>>>>>>>postHandle");
Q
qinyingjie 已提交
28 29 30 31
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
32
        log.info("MyInterceptor>>>>>>>>>afterCompletion");
Q
qinyingjie 已提交
33 34 35
    }
}