SpringBoot拦截器的使用与配置
一、新建拦截器实现HandlerInterceptor接口
判断是否登录的拦截器
package com.briup.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;
public class isLoginInterceptor implements HandlerInterceptor{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
HttpSession session = request.getSession();
Object obj = session.getAttribute("customer");
System.out.println("isLoginInterceptor");
if(obj!=null) {
return true;
}