From a27be660fe5a830ef6083065487a6185f04bb160 Mon Sep 17 00:00:00 2001 From: zxb <919411476@qq.com> Date: Mon, 7 Aug 2023 12:35:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=E6=96=B9=E4=BE=BF=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/conf/security/RequestInterceptor.java | 21 +++++++++++++++++++ .../iot/vmp/conf/security/WebConfig.java | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/RequestInterceptor.java create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/WebConfig.java 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