|
@@ -0,0 +1,33 @@
|
|
|
+package com.nokia.esb_socket.config;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.servlet.DispatcherServlet;
|
|
|
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+
|
|
|
+import com.nokia.request_log.interceptor.RequestLogHandlerInterceptor;
|
|
|
+import com.nokia.request_log.servlet.RequestLogDispatcherServlet;
|
|
|
+
|
|
|
+@Configuration
|
|
|
+public class RequestLogConfiguration implements WebMvcConfigurer {
|
|
|
+ /**
|
|
|
+ * 添加拦截器
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+ // 添加日志拦截器
|
|
|
+ registry.addInterceptor(new RequestLogHandlerInterceptor()).addPathPatterns("/**");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注入自定义的RequestLogDispatcherServlet替代默认的DispatcherServlet
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ @Qualifier(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
|
|
|
+ public DispatcherServlet dispatcherServlet() {
|
|
|
+ return new RequestLogDispatcherServlet();
|
|
|
+ }
|
|
|
+}
|