diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/RequestInterceptor.java b/src/main/java/com/genersoft/iot/vmp/conf/security/RequestInterceptor.java new file mode 100644 index 00000000..ee1f0c07 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/RequestInterceptor.java @@ -0,0 +1,21 @@ +package com.genersoft.iot.vmp.conf.security; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Slf4j +@Component +@SuppressWarnings({"unused"}) +@RequiredArgsConstructor +public class RequestInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + log.info("访问 {}",request.getRequestURI()); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebConfig.java new file mode 100644 index 00000000..b5e9bee5 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebConfig.java @@ -0,0 +1,21 @@ +package com.genersoft.iot.vmp.conf.security; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class WebConfig implements WebMvcConfigurer { + private final RequestInterceptor requestInterceptor; + @Override + public void addInterceptors(@NotNull InterceptorRegistry registry) { + registry.addInterceptor(requestInterceptor) + .excludePathPatterns("/index/hook/**") + .addPathPatterns("/**"); + } +} \ No newline at end of file