package com.daming.reggie_start.interceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
@Slf4j
public class MvcSupport extends WebMvcConfigurationSupport {
@Autowired
public loginInterceptor interceptor;
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("backend/**").addResourceLocations("classpath:/backend/");
}
@Override
protected void addInterceptors(InterceptorRegistry registry) {
log.info("正在拦截中......");
registry.addInterceptor(interceptor).addPathPatterns("/**");
}
}
public class loginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String URI= request.getRequestURI();
log.info("URI ======》"+URI);//此处URI为error
return true;
}
}
上面是拦截路径以及拦截器的preHandle方法、为什么URI总是error
下面是项目结构

controller中的URI没问题